flake.nix: switch to flake parts
Currently, there has been no functional change to the structure of this flake. I have simply wrapped the current flake outputs in the root flake-parts module.
This commit is contained in:
parent
6975b56de2
commit
63c5fd0f6a
33
flake.lock
generated
33
flake.lock
generated
@ -273,6 +273,24 @@
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1738453229,
|
||||
"narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts_2": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"lanzaboote",
|
||||
@ -966,7 +984,7 @@
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-compat": "flake-compat_2",
|
||||
"flake-parts": "flake-parts",
|
||||
"flake-parts": "flake-parts_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
@ -1113,6 +1131,18 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1738452942,
|
||||
"narHash": "sha256-vJzFZGaCpnmo7I6i416HaBLpC+hvcURh/BQwROcGIp8=",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
|
||||
}
|
||||
},
|
||||
"nixpkgs-nix-du": {
|
||||
"locked": {
|
||||
"lastModified": 1722785290,
|
||||
@ -1231,6 +1261,7 @@
|
||||
"inputs": {
|
||||
"agenix": "agenix",
|
||||
"base16": "base16",
|
||||
"flake-parts": "flake-parts",
|
||||
"home-manager": "home-manager_2",
|
||||
"home-manager-unstable": "home-manager-unstable",
|
||||
"hypridle": "hypridle",
|
||||
|
181
flake.nix
181
flake.nix
@ -11,6 +11,8 @@
|
||||
# this seems to be a popular way to declare systems
|
||||
systems.url = "github:nix-systems/default";
|
||||
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager/release-23.11";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
@ -102,8 +104,17 @@
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, nixpkgs-unstable, ... }@inputs:
|
||||
let
|
||||
outputs = {
|
||||
self,
|
||||
flake-parts,
|
||||
...
|
||||
} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} ({
|
||||
inputs,
|
||||
self,
|
||||
...
|
||||
} @ flakeArgs: let
|
||||
inherit (inputs) nixpkgs nixpkgs-unstable;
|
||||
inherit (self) outputs;
|
||||
# inputs is already defined
|
||||
lib = nixpkgs.lib;
|
||||
@ -113,7 +124,8 @@
|
||||
nix-minecraft-patched-overlay = let
|
||||
normal = inputs.nix-minecraft-upstream.overlays.default;
|
||||
quilt = inputs.nix-minecraft.overlays.default;
|
||||
in lib.composeExtensions
|
||||
in
|
||||
lib.composeExtensions
|
||||
normal
|
||||
(final: prev: let
|
||||
x = quilt final prev;
|
||||
@ -162,29 +174,40 @@
|
||||
# This function produces a module that adds the home-manager module to the
|
||||
# system and configures the given module to the user's Home Manager
|
||||
# configuration
|
||||
homeManagerInit = let _username=username; _nixpkgs=nixpkgs;
|
||||
in { system,
|
||||
homeManagerInit = let
|
||||
_username = username;
|
||||
_nixpkgs = nixpkgs;
|
||||
in
|
||||
{
|
||||
system,
|
||||
nixpkgs ? _nixpkgs, # this is so modules can know which flake the system is using
|
||||
home-manager ? inputs.home-manager,
|
||||
username ? _username,
|
||||
module ? _: {},
|
||||
rootModule ? (import ./home/root.nix),
|
||||
userModules ? { ${username} = [ module ] ; root = [ rootModule ]; },
|
||||
stateVersion }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
mapUserModules = lib.attrsets.mapAttrs (user: modules: {...}:
|
||||
{
|
||||
imports = [
|
||||
userModules ? {
|
||||
${username} = [module];
|
||||
root = [rootModule];
|
||||
},
|
||||
stateVersion,
|
||||
}: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
mapUserModules = lib.attrsets.mapAttrs (user: modules: {...}: {
|
||||
imports =
|
||||
[
|
||||
./home
|
||||
] ++ modules;
|
||||
]
|
||||
++ modules;
|
||||
config = {
|
||||
home = {inherit stateVersion;};
|
||||
};
|
||||
});
|
||||
users = mapUserModules userModules;
|
||||
in
|
||||
{
|
||||
in {
|
||||
imports = [
|
||||
home-manager.nixosModules.home-manager
|
||||
];
|
||||
@ -206,7 +229,9 @@
|
||||
mkSystemN = let
|
||||
_username = username;
|
||||
_overlays = overlays;
|
||||
in { nixpkgs ? inputs.nixpkgs,
|
||||
in
|
||||
{
|
||||
nixpkgs ? inputs.nixpkgs,
|
||||
home-manager ? inputs.home-manager,
|
||||
username ? _username,
|
||||
entrypoint ? ./system,
|
||||
@ -215,31 +240,49 @@
|
||||
config ? {},
|
||||
overlays ? _overlays,
|
||||
system,
|
||||
... }@args: let
|
||||
_modules = [ entrypoint config ] ++ modules ++ [{
|
||||
...
|
||||
} @ args: let
|
||||
_modules =
|
||||
[entrypoint config]
|
||||
++ modules
|
||||
++ [
|
||||
{
|
||||
nixpkgs.config = {
|
||||
inherit overlays;
|
||||
allowUnfree = true;
|
||||
};
|
||||
}] ++ lib.optional (args ? stateVersion) { config.system.stateVersion = stateVersion; };
|
||||
in nixpkgs.lib.nixosSystem {
|
||||
}
|
||||
]
|
||||
++ lib.optional (args ? stateVersion) {config.system.stateVersion = stateVersion;};
|
||||
in
|
||||
nixpkgs.lib.nixosSystem {
|
||||
};
|
||||
mkSystem = let _username=username; _overlays=overlays; _nixpkgs=nixpkgs;
|
||||
in { system,
|
||||
mkSystem = let
|
||||
_username = username;
|
||||
_overlays = overlays;
|
||||
_nixpkgs = nixpkgs;
|
||||
in
|
||||
{
|
||||
system,
|
||||
nixpkgs ? _nixpkgs,
|
||||
home-manager ? inputs.home-manager,
|
||||
overlays ? _overlays,
|
||||
hostname,
|
||||
username ? _username,
|
||||
stateVersion,
|
||||
extraModules ? [] }:
|
||||
|
||||
extraModules ? [],
|
||||
}:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
modules =
|
||||
[
|
||||
./system
|
||||
({pkgs, config, lib, ...}@args:
|
||||
{
|
||||
({
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
} @ args: {
|
||||
# Values for every single system that would not conceivably need
|
||||
# to be made modular
|
||||
system.stateVersion = stateVersion;
|
||||
@ -258,14 +301,21 @@
|
||||
module = import ./hosts/${hostname}/home.nix;
|
||||
inherit username system stateVersion;
|
||||
})
|
||||
] ++ extraModules;
|
||||
]
|
||||
++ extraModules;
|
||||
specialArgs = {
|
||||
inherit inputs outputs vars nixpkgs home-manager;
|
||||
};
|
||||
};
|
||||
|
||||
mkWSLSystem = let _username=username; in
|
||||
{username ? _username, extraModules ? [], ...}@args: let
|
||||
mkWSLSystem = let
|
||||
_username = username;
|
||||
in
|
||||
{
|
||||
username ? _username,
|
||||
extraModules ? [],
|
||||
...
|
||||
} @ args: let
|
||||
WSLModule = {...}: {
|
||||
imports = [
|
||||
inputs.nix-wsl.nixosModules.wsl
|
||||
@ -277,12 +327,17 @@
|
||||
in
|
||||
mkSystem (args // override);
|
||||
|
||||
mkISOSystem = system: inputs.nixpkgs-unstable.lib.nixosSystem {
|
||||
mkISOSystem = system:
|
||||
inputs.nixpkgs-unstable.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
"${inputs.nixpkgs-unstable}/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix"
|
||||
({ config, pkgs, lib, ... }:
|
||||
{
|
||||
({
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
environment.systemPackages = with pkgs; [
|
||||
neovim
|
||||
gparted
|
||||
@ -301,7 +356,9 @@
|
||||
_home-manager = inputs.home-manager;
|
||||
_nixpkgs = inputs.nixpkgs;
|
||||
_username = username;
|
||||
in { home-manager ? _home-manager,
|
||||
in
|
||||
{
|
||||
home-manager ? _home-manager,
|
||||
nixpkgs ? _nixpkgs,
|
||||
username ? _username,
|
||||
homeDirectory ? "/home/${username}",
|
||||
@ -310,8 +367,13 @@
|
||||
stateVersion ? null,
|
||||
config ? {},
|
||||
system,
|
||||
... }@args: let
|
||||
_modules = [ entrypoint ] ++ modules ++ [ config ] ++ [
|
||||
...
|
||||
} @ args: let
|
||||
_modules =
|
||||
[entrypoint]
|
||||
++ modules
|
||||
++ [config]
|
||||
++ [
|
||||
{
|
||||
config = {
|
||||
home = {
|
||||
@ -322,8 +384,10 @@
|
||||
};
|
||||
};
|
||||
}
|
||||
] ++ lib.optional (args ? stateVersion) { config.home.stateVersion = stateVersion; };
|
||||
in home-manager.lib.homeManagerConfiguration ({
|
||||
]
|
||||
++ lib.optional (args ? stateVersion) {config.home.stateVersion = stateVersion;};
|
||||
in
|
||||
home-manager.lib.homeManagerConfiguration ({
|
||||
modules = _modules;
|
||||
pkgs = import nixpkgs {inherit system overlays;};
|
||||
|
||||
@ -333,10 +397,11 @@
|
||||
# this is needed because modules don't use the default arg for some reason???
|
||||
osConfig = {};
|
||||
};
|
||||
} // builtins.removeAttrs args
|
||||
}
|
||||
// builtins.removeAttrs args
|
||||
["system" "nixpkgs" "home-manager" "modules" "username" "homeDirectory" "stateVersion" "entrypoint" "config"]);
|
||||
|
||||
in {
|
||||
flake = {
|
||||
# for repl debugging via :lf .
|
||||
inherit inputs vars;
|
||||
|
||||
@ -361,16 +426,26 @@
|
||||
# (extraS|s)pecialArgs to pass variables
|
||||
nixosModules = (import ./modules/nixos) moduleInputs;
|
||||
homeManagerModules = (import ./modules/home-manager) moduleInputs;
|
||||
packages = eachSystem (system: let pkgs = import nixpkgs-unstable { inherit system; };
|
||||
in (
|
||||
import ./pkgs { inherit pkgs; }) // {
|
||||
packages = eachSystem (
|
||||
system: let
|
||||
pkgs = import nixpkgs-unstable {inherit system;};
|
||||
in
|
||||
(
|
||||
import ./pkgs {inherit pkgs;}
|
||||
)
|
||||
// {
|
||||
iso = let
|
||||
isoSystem = mkISOSystem system;
|
||||
in isoSystem.config.system.build.isoImage;
|
||||
in
|
||||
isoSystem.config.system.build.isoImage;
|
||||
}
|
||||
);
|
||||
apps = eachSystem (system: import ./pkgs/apps.nix
|
||||
{ inherit (self.outputs) packages; inherit system; });
|
||||
apps = eachSystem (system:
|
||||
import ./pkgs/apps.nix
|
||||
{
|
||||
inherit (self.outputs) packages;
|
||||
inherit system;
|
||||
});
|
||||
|
||||
overlays = import ./overlays self;
|
||||
|
||||
@ -407,9 +482,11 @@
|
||||
system = "x86_64-linux";
|
||||
stateVersion = "24.11";
|
||||
hostname = "rpi4";
|
||||
extraModules = [{
|
||||
extraModules = [
|
||||
{
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
}];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
rpi4 = mkSystem {
|
||||
@ -477,5 +554,9 @@
|
||||
home-manager = inputs.home-manager-unstable;
|
||||
};
|
||||
};
|
||||
}; # end outputs
|
||||
} # end flake
|
||||
};
|
||||
systems = (import inputs.systems);
|
||||
}); # end outputs
|
||||
}
|
||||
# end flake
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user