diff --git a/flake.nix b/flake.nix index 179f3187..cb3267d5 100644 --- a/flake.nix +++ b/flake.nix @@ -106,6 +106,7 @@ inherit system; modules = [ lix-module.nixosModules.default + (import ./nixos/options.nix) (./. + "/nixos/boxes/${hostname}") (import ./nixos/email-accounts.nix) (import ./nixos/common.nix) @@ -171,6 +172,7 @@ system = "aarch64-darwin"; modules = [ lix-module.nixosModules.default + (import ./nixos/options.nix) (./. + "/nixos/boxes/cushy") {users.users."Cyryl.Plotnicki".home = "/Users/Cyryl.Plotnicki";} home-manager.darwinModules.home-manager @@ -196,6 +198,7 @@ system = "aarch64-darwin"; modules = [ lix-module.nixosModules.default + (import ./nixos/options.nix) (./. + "/nixos/boxes/airy") {users.users.cyryl.home = "/Users/cyryl";} home-manager.darwinModules.home-manager diff --git a/nixos/boxes/cushy/default.nix b/nixos/boxes/cushy/default.nix index 1dcce175..6005ea64 100644 --- a/nixos/boxes/cushy/default.nix +++ b/nixos/boxes/cushy/default.nix @@ -5,28 +5,12 @@ lib, nixpkgs-nixos-unstable-and-unfree, ... -}: let - username = "Cyryl.Plotnicki"; -in { +}: { + local.username = "Cyryl.Plotnicki"; imports = [ - (import ../../zsh { - inherit pkgs; - inherit lib; - inherit config; - cyplo.username = username; - }) - (import ../../git { - inherit pkgs; - inherit lib; - inherit config; - cyplo.username = username; - }) - (import ../../helix { - inherit pkgs; - inherit lib; - inherit config; - cyplo.username = username; - }) + ../../zsh + ../../git + ../../helix ]; services.nix-daemon.enable = true; diff --git a/nixos/git/default.nix b/nixos/git/default.nix index 0ac1ec70..40a52b90 100644 --- a/nixos/git/default.nix +++ b/nixos/git/default.nix @@ -2,13 +2,7 @@ config, pkgs, lib, - cyplo, ... -}: let - username = - if cyplo ? username - then "${cyplo.username}" - else "cyryl"; -in { - home-manager.users."${username}" = {...}: {imports = [./home.nix];}; +}: { + home-manager.users."${config.local.username}" = {...}: {imports = [./home.nix];}; } diff --git a/nixos/helix/default.nix b/nixos/helix/default.nix index bb676b58..7da98725 100644 --- a/nixos/helix/default.nix +++ b/nixos/helix/default.nix @@ -2,16 +2,8 @@ config, pkgs, lib, - cyplo, ... -}: -let - username = - if cyplo ? username - then "${cyplo.username}" - else "cyryl"; -in -{ +}: { nix.settings = { trusted-substituters = [ "https://helix.cachix.org" @@ -20,5 +12,5 @@ in "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" ]; }; - home-manager.users."${username}" = {...}: {imports = [./home.nix];}; + home-manager.users."${config.local.username}" = {...}: {imports = [./home.nix];}; } diff --git a/nixos/options.nix b/nixos/options.nix new file mode 100644 index 00000000..b0dd0bce --- /dev/null +++ b/nixos/options.nix @@ -0,0 +1,10 @@ +{ + lib, + pkgs, + ... +}: { + options.local.username = lib.mkOption { + default = "cyryl"; + type = lib.types.str; + }; +} diff --git a/nixos/zsh/default.nix b/nixos/zsh/default.nix index 2b9a6a17..d47cd6e1 100644 --- a/nixos/zsh/default.nix +++ b/nixos/zsh/default.nix @@ -2,14 +2,8 @@ config, pkgs, lib, - cyplo, ... -}: let - username = - if cyplo ? username - then "${cyplo.username}" - else "cyryl"; -in { +}: { programs.zsh.enable = true; - home-manager.users."${username}" = {...}: {imports = [./home.nix];}; + home-manager.users."${config.local.username}" = {...}: {imports = [./home.nix];}; }