Compare commits
No commits in common. "63fef3193e5e4ae86fe0d0088390d627d938312c" and "de72f9a869183b1b214a94eb7b2ca496084fc004" have entirely different histories.
63fef3193e
...
de72f9a869
8 changed files with 21 additions and 161 deletions
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
flake.homes.rafiq = {
|
|
||||||
home.shellAliases = {
|
|
||||||
gs = "git status";
|
|
||||||
gc = "git commit";
|
|
||||||
gcam = "git commit -am";
|
|
||||||
gu = "git push";
|
|
||||||
gy = "git pull";
|
|
||||||
gdh = "git diff HEAD";
|
|
||||||
};
|
|
||||||
programs.git = {
|
|
||||||
signing.signByDefault = true;
|
|
||||||
extraConfig = {
|
|
||||||
init.defaultBranch = "prime";
|
|
||||||
push.autoSetupRemote = true;
|
|
||||||
pull.rebase = false;
|
|
||||||
core.editor = "$EDITOR";
|
|
||||||
gpg.format = "ssh";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -5,92 +5,7 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
flake.lib = {
|
flake.lib = {
|
||||||
/**
|
|
||||||
Remove the top level attributes from an attribute set and return the merged attributes.
|
|
||||||
|
|
||||||
# Inputs
|
|
||||||
|
|
||||||
`attrset`
|
|
||||||
|
|
||||||
: An attribute set to flatten.
|
|
||||||
|
|
||||||
# Type
|
|
||||||
|
|
||||||
```
|
|
||||||
flattenAttrs :: AttrSet -> AttrSet
|
|
||||||
```
|
|
||||||
|
|
||||||
# Examples
|
|
||||||
:::{.example}
|
|
||||||
## `flattenAttrs` usage example
|
|
||||||
|
|
||||||
```nix
|
|
||||||
flattenAttrs { x = { a = 1; b = 2; }; y = { c = 3; d = 4; }; }
|
|
||||||
=> { a = 1; b = 2; c = 3; d = 4; }
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
flattenAttrs = attrset: concatMapAttrs (_: v: v) attrset;
|
flattenAttrs = attrset: concatMapAttrs (_: v: v) attrset;
|
||||||
|
forAllUsers = f: mapAttrs f cfg.manifest.users;
|
||||||
/**
|
|
||||||
Return an attribute set for use with a option that needs to be used for all users.
|
|
||||||
|
|
||||||
# Inputs
|
|
||||||
|
|
||||||
`attrset`
|
|
||||||
|
|
||||||
: An attribute set to apply to all the users.
|
|
||||||
|
|
||||||
# Type
|
|
||||||
|
|
||||||
```
|
|
||||||
forAllUsers :: AttrSet -> AttrSet
|
|
||||||
```
|
|
||||||
|
|
||||||
# Examples
|
|
||||||
:::{.example}
|
|
||||||
## `forAllUsers` usage example
|
|
||||||
|
|
||||||
```nix
|
|
||||||
flake.manifest.users.rafiq = { ... };
|
|
||||||
flake.modules.nixos.default.users = forAllUsers {
|
|
||||||
isNormalUser = true;
|
|
||||||
};
|
|
||||||
=> flake.modules.nixos.default.users.rafiq.isNormalUser = true;
|
|
||||||
```
|
|
||||||
|
|
||||||
:::
|
|
||||||
*/
|
|
||||||
forAllUsers = attrset: mapAttrs (_: _: attrset) cfg.manifest.users;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Like forAllUsers, but passes in the name and value from the manifest.
|
|
||||||
|
|
||||||
# Inputs
|
|
||||||
|
|
||||||
`f`
|
|
||||||
|
|
||||||
: A function that takes an attribute name and its value, and returns the new value for the attribute.
|
|
||||||
|
|
||||||
# Type
|
|
||||||
|
|
||||||
```
|
|
||||||
forAllUsers' :: (String -> Any -> Any) -> AttrSet
|
|
||||||
```
|
|
||||||
|
|
||||||
# Examples
|
|
||||||
:::{.example}
|
|
||||||
## `forAllUsers'` usage example
|
|
||||||
|
|
||||||
```nix
|
|
||||||
flake.manifest.users.rafiq = { ... };
|
|
||||||
flake.modules.homeManager.users = forAllUsers' (name: value: {
|
|
||||||
home.username = name;
|
|
||||||
});
|
|
||||||
=> flake.modules.homeManager.default.users.rafiq.home.username = "rafiq";
|
|
||||||
```
|
|
||||||
|
|
||||||
:::
|
|
||||||
*/
|
|
||||||
forAllUsers' = f: mapAttrs f cfg.manifest.users;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ in
|
||||||
flake.manifest = {
|
flake.manifest = {
|
||||||
users.rafiq = {
|
users.rafiq = {
|
||||||
primary = true;
|
primary = true;
|
||||||
name = "Mohammad Rafiq";
|
username = "rafiq"; # If we don't set this here we have to do some weird shit
|
||||||
email = "rafiq@rrv.sh";
|
email = "rafiq@rrv.sh";
|
||||||
shell = "fish";
|
shell = "fish";
|
||||||
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n rafiq";
|
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n rafiq";
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
flake.modules.homeManager.default =
|
|
||||||
{ manifest, config, ... }:
|
|
||||||
{
|
|
||||||
home.sessionVariables.GIT_CONFIG_GLOBAL = "$HOME/.config/git/config";
|
|
||||||
programs.git = {
|
|
||||||
userName = manifest.users.${config.home.username}.name;
|
|
||||||
userEmail = manifest.users.${config.home.username}.email;
|
|
||||||
signing.key = "~/.ssh/id_ed25519.pub";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,16 +1,14 @@
|
||||||
{ inputs, config, ... }:
|
{ inputs, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (cfg.lib) forAllUsers' flattenAttrs;
|
inherit (cfg.lib) flattenAttrs;
|
||||||
cfg = config.flake;
|
cfg = config.flake;
|
||||||
hm = inputs.home-manager;
|
hm = inputs.home-manager;
|
||||||
globalCfg = {
|
globalCfg = {
|
||||||
useGlobalPkgs = true;
|
useGlobalPkgs = true;
|
||||||
useUserPackages = true;
|
useUserPackages = true;
|
||||||
extraSpecialArgs = { inherit (cfg) manifest; };
|
|
||||||
sharedModules = [
|
sharedModules = [
|
||||||
(flattenAttrs (cfg.modules.homeManager or { }))
|
(flattenAttrs (cfg.modules.homeManager or { }))
|
||||||
];
|
];
|
||||||
users = forAllUsers' (name: _: cfg.homes.${name});
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,6 @@ let
|
||||||
nixosSystem {
|
nixosSystem {
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
inherit (cfg) manifest;
|
|
||||||
hostName = name;
|
hostName = name;
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
{ config, lib, ... }:
|
|
||||||
let
|
|
||||||
cfg = config.flake;
|
|
||||||
inherit (cfg.lib) forAllUsers';
|
|
||||||
inherit (lib.attrsets) mapAttrs';
|
|
||||||
in
|
|
||||||
{
|
|
||||||
flake.modules.nixos.default =
|
|
||||||
{ pkgs, ... }:
|
|
||||||
{
|
|
||||||
programs = mapAttrs' (name: value: {
|
|
||||||
name = value.shell;
|
|
||||||
value.enable = true;
|
|
||||||
}) cfg.manifest.users;
|
|
||||||
users.users = forAllUsers' (_: value: { shell = pkgs.${value.shell}; });
|
|
||||||
};
|
|
||||||
flake.modules.homeManager.default =
|
|
||||||
{ config, ... }:
|
|
||||||
{
|
|
||||||
programs.${cfg.manifest.users.${config.home.username}.shell}.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,31 +1,35 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.flake;
|
cfg = config.flake;
|
||||||
inherit (cfg.lib) forAllUsers';
|
inherit (config.flake.lib) forAllUsers flattenAttrs;
|
||||||
inherit (lib.lists) optional;
|
inherit (lib.attrsets) filterAttrs;
|
||||||
|
owner = flattenAttrs (filterAttrs (_: v: (v.primary or false)) cfg.manifest.users);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
flake.modules.nixos.default =
|
flake.modules.nixos.default =
|
||||||
{ config, ... }:
|
{ pkgs, config, ... }:
|
||||||
{
|
{
|
||||||
#TODO: move sudo/security options elsewhere
|
#TODO: move sudo/security options elsewhere
|
||||||
# security.sudo.wheelNeedsPassword = false;
|
security.sudo.wheelNeedsPassword = false;
|
||||||
# nix.settings.trusted-users = [ "@wheel" ];
|
nix.settings.trusted-users = [ "@wheel" ];
|
||||||
|
#TODO: move to shell config
|
||||||
|
programs.${owner.shell}.enable = true;
|
||||||
#TODO: move ssh key settings elsewhere
|
#TODO: move ssh key settings elsewhere
|
||||||
# users.users.root.openssh.authorizedKeys.keys = [ owner.pubkey ];
|
|
||||||
users = {
|
users = {
|
||||||
mutableUsers = false;
|
mutableUsers = false;
|
||||||
groups.users.gid = 100;
|
groups.users.gid = 100;
|
||||||
users = forAllUsers' (
|
users.root.openssh.authorizedKeys.keys = [ owner.pubkey ];
|
||||||
_: value: {
|
users.${owner.username} = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = optional (value.primary or false) "wheel";
|
# hashedPasswordFile
|
||||||
openssh.authorizedKeys.keys = [ value.pubkey ];
|
extraGroups = [ "wheel" ];
|
||||||
}
|
shell = pkgs.${owner.shell};
|
||||||
);
|
openssh.authorizedKeys.keys = [ owner.pubkey ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
home-manager.users = forAllUsers' (
|
home-manager.users = forAllUsers (
|
||||||
name: _: {
|
name: _: {
|
||||||
|
#TODO: move into nixos/darwin config - should not apply to homeConfigurations
|
||||||
home.username = name;
|
home.username = name;
|
||||||
home.homeDirectory = config.users.users.${name}.home;
|
home.homeDirectory = config.users.users.${name}.home;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue