Skip to content

Commit

Permalink
Try #156:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Mar 23, 2021
2 parents b7cb975 + 26f6357 commit 14812ed
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 30 deletions.
13 changes: 8 additions & 5 deletions extern/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{ inputs }: with inputs;
let
hmModules = { };
in
{
modules = [
home.nixosModules.home-manager
Expand All @@ -20,9 +17,15 @@ in

# passed to all nixos modules
specialArgs = {
inherit hmModules;

overrideModulesPath = "${override}/nixos/modules";
hardware = nixos-hardware.nixosModules;
};

# added to home-manager
userModules = [
];

# passed to all home-manager modules
userSpecialArgs = {
};
}
9 changes: 6 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@
});
});

homeConfigurations = os.mkHomeConfigurations;

nixosModules =
let moduleList = import ./modules/module-list.nix;
in lib.pathsToImportedAttrs moduleList;

homeModules =
let moduleList = import ./users/modules/module-list.nix;
in lib.pathsToImportedAttrs moduleList;

overlay = import ./pkgs;
overlays = lib.pathsToImportedAttrs (lib.pathsIn ./overlays);

Expand Down Expand Up @@ -83,9 +89,6 @@
devShell = import ./shell {
inherit self system;
};

legacyPackages.hmActivationPackages =
os.mkHomeActivation;
}
);
in
Expand Down
11 changes: 8 additions & 3 deletions hosts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ let
};

global = { config, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;

extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules);
};

hardware.enableRedistributableFirmware = lib.mkDefault true;

Expand All @@ -54,7 +59,7 @@ let
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
};

specialArgs = extern.specialArgs // { inherit suites; };
specialArgs = extern.specialArgs // { suites = suites.system; };

mkHostConfig = hostName:
let
Expand Down
2 changes: 1 addition & 1 deletion lib/devos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

devosSystem = dev.callLibs ./devosSystem.nix;

mkHomeActivation = dev.callLibs ./mkHomeActivation.nix;
mkHomeConfigurations = dev.callLibs ./mkHomeConfigurations.nix;

mkPackages = dev.callLibs ./mkPackages.nix;
}
Expand Down
19 changes: 19 additions & 0 deletions lib/devos/devosSystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,29 @@ lib.nixosSystem (args // {
})
];
})).config;
hmConfig = (lib.nixosSystem
(args // {
modules = modules ++ [
({ config, ... }: {
home-manager.useUserPackages = lib.mkForce false;
home-manager.sharedModules = [
{
home.packages = config.environment.systemPackages;
home.sessionVariables = {
inherit (config.environment.sessionVariables) NIX_PATH;
};
xdg.configFile."nix/registry.json".text =
config.environment.etc."nix/registry.json".text;
}
];
})
];
})).config;
in
moduleList ++ [{
system.build = {
iso = isoConfig.system.build.isoImage;
homes = hmConfig.home-manager.users;
};
}];
})
12 changes: 0 additions & 12 deletions lib/devos/mkHomeActivation.nix

This file was deleted.

12 changes: 12 additions & 0 deletions lib/devos/mkHomeConfigurations.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ lib, self, ... }:

with lib;
let
mkHomes = host: config:
mapAttrs' (user: v: nameValuePair "${user}@${host}" v)
config.config.system.build.homes;

hmConfigs = mapAttrs mkHomes self.nixosConfigurations;

in
foldl recursiveUpdate {} (attrValues hmConfigs)
2 changes: 1 addition & 1 deletion shell/flk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ case "$1" in
;;

"home")
ref="$DEVSHELL_ROOT/#hmActivationPackages.$2.$3"
ref="$DEVSHELL_ROOT/#homeConfigurations.$3@$2.home.activationPackage"

if [[ "$4" == "switch" ]]; then
nix build "$ref" && result/activate &&
Expand Down
16 changes: 14 additions & 2 deletions suites/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ let
inherit (lib) dev;

profiles = dev.os.mkProfileAttrs (toString ../profiles);
userProfiles = dev.os.mkProfileAttrs (toString ../users/profiles);
users = dev.os.mkProfileAttrs (toString ../users);

allProfiles =
Expand All @@ -17,7 +18,18 @@ let
suites = with profiles; rec {
base = [ users.nixos users.root ];
};

# available as 'suites' within the home-manager configuration
userSuites = with userProfiles; rec {
base = [ direnv git ];
};

in
lib.mapAttrs (_: v: dev.os.profileMap v) suites // {
inherit allProfiles allUsers;
{
system = lib.mapAttrs (_: v: dev.os.profileMap v) suites // {
inherit allProfiles allUsers;
};
user = lib.mapAttrs (_: v: dev.os.profileMap v) userSuites // {
allProfiles = userProfiles;
};
}
2 changes: 1 addition & 1 deletion users/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ flk home NixOS nixos switch
### Manually from outside the project:
```sh
# build
nix build "github:divnix/devos#hmActivationPackages.NixOS.nixos"
nix build "github:divnix/devos#homeConfigurations.NixOS-nixos.home.activationPackage"

# activate
./result/activate && unlink result
Expand Down
1 change: 1 addition & 0 deletions users/modules/module-list.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
4 changes: 2 additions & 2 deletions users/nixos/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ ... }:
{
home-manager.users.nixos = {
imports = [ ../profiles/git ../profiles/direnv ];
home-manager.users.nixos = { suites, ... }: {
imports = suites.base;
};

users.users.nixos = {
Expand Down

0 comments on commit 14812ed

Please sign in to comment.