From 46152e140fe428538a562dcfd1627a88a02dcc09 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 13 Mar 2022 10:41:41 +0100 Subject: ... --- accounts/gkleen@sif/default.nix | 1 + flake.nix | 4 +++- installer/default.nix | 2 ++ modules/home-manager.nix | 13 ++++++++++ system-profiles/rebuild-machines/default.nix | 28 +++++++++++++++++++--- .../rebuild-machines/rebuild-machine.zsh | 2 +- user-profiles/core.nix | 27 +++++++++++++-------- 7 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 modules/home-manager.nix diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index 84ac88a7..4322278e 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -192,6 +192,7 @@ in { package = import ./taffybar { inherit (pkgs) haskellPackages; }; }; status-notifier-watcher.enable = true; + xembed-sni-proxy.enable = true; pasystray.enable = true; udiskie = { enable = true; diff --git a/flake.nix b/flake.nix index 597ac14a..5e5e6d0d 100644 --- a/flake.nix +++ b/flake.nix @@ -136,6 +136,8 @@ packages = let installerPackages = system: optionalAttrs (!(isNull installerConfig)) (mapAttrs' (profile: value: nameValuePair "installer-${profile}" value.output) installers.${system}); in forAllSystems (system: systemPkgs: self.overlays.default (self.legacyPackages.${system}) systemPkgs // installerPackages system); + + activateHomeManager = system: base: (deploy-rs.lib.${system}.activate.custom // { dryActivate = "DRY_RUN=1 $PROFILE/activate"; }) base.activationPackage "$PROFILE/activate"; in { nixosModules = @@ -183,7 +185,7 @@ }; } // (mapAttrs (_user: usercfg: { user = usercfg.home.username; - path = deploy-rs.lib.${self.nixosConfigurations.${hostname}.config.nixpkgs.system}.activate.home-manager usercfg.home; + path = activateHomeManager (self.nixosConfigurations.${hostname}.config.nixpkgs.system) usercfg.home; }) self.nixosConfigurations.${hostname}.config.home-manager.users); }) (nixImport { dir = ./hosts; _import = (_path: name: name); }); diff --git a/installer/default.nix b/installer/default.nix index bf09c8d8..ad0c3849 100644 --- a/installer/default.nix +++ b/installer/default.nix @@ -28,5 +28,7 @@ ]; zramSwap.enable = true; + + home-manager.enableSystemd = true; }; } diff --git a/modules/home-manager.nix b/modules/home-manager.nix new file mode 100644 index 00000000..9c259381 --- /dev/null +++ b/modules/home-manager.nix @@ -0,0 +1,13 @@ +{ lib, ... }: + +with lib; + +{ + options = { + home-manager.enableSystemd = mkOption { + type = types.bool; + default = false; + example = true; + }; + }; +} diff --git a/system-profiles/rebuild-machines/default.nix b/system-profiles/rebuild-machines/default.nix index 68788023..fe9a5f14 100644 --- a/system-profiles/rebuild-machines/default.nix +++ b/system-profiles/rebuild-machines/default.nix @@ -26,7 +26,9 @@ let phases = [ "buildPhase" "installPhase" ]; inherit (pkgs) zsh coreutils openssh; - inherit (cfg) flake scriptName; + inherit (cfg) scriptName; + inherit (cfg.flake) flakeOutput; + flake = cfg.flake.name; nixosRebuild = config.system.build.nixos-rebuild; inherit (config.security) wrapperDir; inherit sshConfig; @@ -52,8 +54,21 @@ in { }; flake = mkOption { - type = types.nullOr types.str; - default = "git+ssh://${cfg.repoHost}/nixos?ref=flakes#${hostName}"; + type = types.submodule { + options = { + flake = mkOption { + type = types.attrs; + }; + flakeOutput = mkOption { + type = types.str; + }; + name = mkOption { + type = types.str; + default = "machines"; + }; + }; + }; + default = { flake.url = "git+ssh://${cfg.repoHost}/nixos?ref=flakes"; flakeOutput = hostName; }; description = '' The Flake URI of the NixOS configuration to build. ''; @@ -136,5 +151,12 @@ in { Persistent = true; }; }; + + nix.registry = lib.mkIf (cfg.flake != null) { + ${cfg.flake.name} = { + exact = false; + to = cfg.flake.flake; + }; + }; }; } diff --git a/system-profiles/rebuild-machines/rebuild-machine.zsh b/system-profiles/rebuild-machines/rebuild-machine.zsh index c06ef0e4..e018e7a7 100644 --- a/system-profiles/rebuild-machines/rebuild-machine.zsh +++ b/system-profiles/rebuild-machines/rebuild-machine.zsh @@ -7,4 +7,4 @@ fi export NIX_SSHOPTS="-F @sshConfig@" export GIT_SSH_COMMAND="@openssh@/bin/ssh -F @sshConfig@" export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="init.defaultBranch" GIT_CONFIG_VALUE_0=main -exec -- @nixosRebuild@/bin/nixos-rebuild --refresh --flake '@flake@' ${@:-switch} +exec -- @nixosRebuild@/bin/nixos-rebuild --refresh --flake '@flake@#@flakeOutput@' ${@:-switch} diff --git a/user-profiles/core.nix b/user-profiles/core.nix index cb2c400e..cf5db3b6 100644 --- a/user-profiles/core.nix +++ b/user-profiles/core.nix @@ -1,14 +1,21 @@ -{ flake, userName, lib, ... }: +{ flake, userName, config, lib, utils, ... }: { - users.users.${userName} = {}; # Just make sure the user is created - - home-manager.users.${userName} = { - imports = lib.attrValues flake.homeModules; - - config = { - manual.manpages.enable = true; - home.stateVersion = "20.09"; - systemd.user.startServices = "sd-switch"; + config = { + users.users.${userName} = {}; # Just make sure the user is created + + home-manager.users.${userName} = { + imports = lib.attrValues flake.homeModules; + + config = { + manual.manpages.enable = true; + home.stateVersion = "20.09"; + systemd.user.startServices = "sd-switch"; + + }; + }; + + systemd.services."home-manager-${utils.escapeSystemdPath userName}" = lib.mkIf config.home-manager.enableSystemd { + enable = false; # deploy with deploy-rs }; }; } -- cgit v1.2.3