Compare commits

..

2 Commits

Author SHA1 Message Date
c869ec0fe3
flake: migrate nixosConfigurations to new config 2025-02-14 00:39:50 -05:00
4aac8ea9ad
flake/system: fully working mkSystem replacement
for some reason, the toplevel derivation is different for some systems,
but nix-diff only shows one file being different, specifically the order
of some config relating to kernel modules. however, the produced system
is functionally identical. i have no idea what could be responsible for
this change.
2025-02-14 00:30:30 -05:00
3 changed files with 83 additions and 67 deletions

View File

@ -181,10 +181,27 @@
nix-minecraft-patched-overlay nix-minecraft-patched-overlay
]; ];
systems.testsys = { systems = {
system = "x86_64-linux"; slab.system = "x86_64-linux";
enable = false; nullbox.system = "x86_64-linux";
}; rpi4.system = "aarch64-linux";
nixos-wsl = {
system = "x86_64-linux";
wsl = true;
};
# for eval testing
rpi4-x86_64 = {
system = "x86_64-linux";
name = "rpi4";
modules = [
{
nixpkgs.hostPlatform = "x86_64-linux";
}
];
};
}; # end systems
}; };
flake = let flake = let
@ -284,51 +301,6 @@
nixosConfigurations = { nixosConfigurations = {
iso = mkISOSystem "x86_64-linux"; iso = mkISOSystem "x86_64-linux";
slab = mkSystem {
nixpkgs = inputs.nixpkgs-unstable;
home-manager = inputs.home-manager-unstable;
system = "x86_64-linux";
hostname = "slab";
stateVersion = "23.11";
};
nullbox = mkSystem {
nixpkgs = inputs.nixpkgs-unstable;
home-manager = inputs.home-manager-unstable;
system = "x86_64-linux";
hostname = "nullbox";
stateVersion = "23.11";
};
nixos-wsl = mkWSLSystem {
nixpkgs = inputs.nixpkgs-unstable;
home-manager = inputs.home-manager-unstable;
system = "x86_64-linux";
stateVersion = "23.11";
hostname = "nixos-wsl";
};
# for eval testing
rpi4-x86_64 = mkSystem {
nixpkgs = inputs.nixpkgs-unstable;
home-manager = inputs.home-manager-unstable;
system = "x86_64-linux";
stateVersion = "24.11";
hostname = "rpi4";
extraModules = [
{
nixpkgs.hostPlatform = "x86_64-linux";
}
];
};
rpi4 = mkSystem {
nixpkgs = inputs.nixpkgs-unstable;
home-manager = inputs.home-manager-unstable;
system = "aarch64-linux";
stateVersion = "24.11";
hostname = "rpi4";
};
}; # end nixosConfigurations }; # end nixosConfigurations
homeConfigurations = { homeConfigurations = {

View File

@ -17,9 +17,9 @@
mapAttrs mapAttrs
; ;
inherit (builtins) attrNames; inherit (builtins) attrNames isNull;
inherit (nixfiles-lib.flake-legacy) mkSystem mkHome mkWSLSystem mkISOSystem; inherit (nixfiles-lib.flake-legacy) mkSystem mkHome mkWSLSystem mkISOSystem homeManagerInit;
inherit (nixfiles-lib.types) mkCheckedType; inherit (nixfiles-lib.types) mkCheckedType;
mkConfigurationOption = systemType: mkConfigurationOption = systemType:
@ -70,7 +70,7 @@ in {
}; };
modules = mkOption { modules = mkOption {
description = "NixOS modules"; description = "Extra NixOS configuration modules.";
type = with types; listOf deferredModule; type = with types; listOf deferredModule;
default = []; default = [];
}; };
@ -85,10 +85,16 @@ in {
default = name; default = name;
}; };
configPath = mkOption { configRoot = mkOption {
description = "Path to main system configuration module."; description = "Path to directory containing system and home configuration modules.";
type = lib.types.path; type = lib.types.path;
default = self + "/hosts/${config.name}/configuration.nix"; default = self + "/hosts/${config.name}";
};
configuration = mkOption {
description = "Path/module of main NixOS configuration.";
type = with types; nullOr deferredModule;
default = config.configRoot + "/configuration.nix";
}; };
home-manager = { home-manager = {
@ -107,14 +113,14 @@ in {
default = inputs.home-manager-unstable; default = inputs.home-manager-unstable;
}; };
configPath = mkOption { configuration = mkOption {
description = "Path to main home configuration module."; description = "Path/module of main home-manager configuration.";
type = lib.types.path; type = with types; nullOr deferredModule;
default = self + "/hosts/${config.name}/home.nix"; default = config.configRoot + "/home.nix";
}; };
modules = mkOption { modules = mkOption {
description = "home-manager modules"; description = "Extra home-manager modules";
type = with types; listOf deferredModule; type = with types; listOf deferredModule;
}; };
}; };
@ -162,15 +168,53 @@ in {
wsl.enable = true; wsl.enable = true;
wsl.defaultUser = outerConfig.nixfiles.vars.username; wsl.defaultUser = outerConfig.nixfiles.vars.username;
}; };
homeManagerModule = let
homeManagerModuleInner = homeManagerInit {
inherit (config) nixpkgs system;
inherit (outerConfig.nixfiles.vars) username;
home-manager = config.home-manager.input;
module =
if (isNull config.home-manager.configuration)
then {}
else config.home-manager.configuration;
};
in
{
config,
pkgs,
lib,
...
}: let
inheritStateVersionModule = {lib, ...}: {
config = {
home.stateVersion = lib.mkDefault config.system.stateVersion;
};
};
in {
imports = [
# TODO placeholder using old function
homeManagerModuleInner
];
# previously, home-manager inherited stateVersion from nixos in
# a really hacky way that depended on the wrapper function.
# this should preserve that behavior in a much safer way by
# directly setting it in a module. ideally, it should probably
# be set manually, but I want to maintain backwards
# compatibility for now
options.home-manager.users = lib.mkOption {
type = with lib.types; attrsOf (submodule inheritStateVersionModule);
};
};
in in
[ [
nixfilesModule nixfilesModule
defaultsModule defaultsModule
# TODO
# import /hosts/ path
# home manager init
] ]
++ lib.optionals config.wsl wslModule; ++ lib.optional (!(isNull config.configuration)) config.configuration
++ lib.optional config.home-manager.enable homeManagerModule
++ lib.optional config.wsl wslModule;
extraConfig = { extraConfig = {
inherit (config) system modules; inherit (config) system modules;
# TODO get rid of specialArgs and pass things as a module # TODO get rid of specialArgs and pass things as a module

View File

@ -44,21 +44,21 @@ in rec {
${username} = [module]; ${username} = [module];
root = [rootModule]; root = [rootModule];
}, },
stateVersion, stateVersion ? null,
}: { }: {
config, config,
lib, lib,
pkgs, pkgs,
... ...
}: let }: let
mapUserModules = lib.attrsets.mapAttrs (user: modules: {...}: { mapUserModules = lib.attrsets.mapAttrs (user: modules: {lib, ...}: {
imports = imports =
[ [
(self + "/home") (self + "/home")
] ]
++ modules; ++ modules;
config = { config = {
home = {inherit stateVersion;}; home = lib.mkIf (!(builtins.isNull stateVersion)) {inherit stateVersion;};
}; };
}); });
users = mapUserModules userModules; users = mapUserModules userModules;