various refactors
* Move extern lists to their own folder * Move unstable package and module imports to their own folder * Create a genPkgs function to avoid using legacyPackages for the whole package set * Move hmActivationPackages to legacyPackages
This commit is contained in:
parent
7b404f587d
commit
0ec0c25238
8 changed files with 114 additions and 96 deletions
|
@ -19,7 +19,8 @@ Some key advantages include:
|
||||||
* Defined [packages](./pkgs/default.nix) and
|
* Defined [packages](./pkgs/default.nix) and
|
||||||
[modules](./modules/list.nix), are automatically wired and available from
|
[modules](./modules/list.nix), are automatically wired and available from
|
||||||
anywhere. They are _also_ sharable via their respective flake outputs.
|
anywhere. They are _also_ sharable via their respective flake outputs.
|
||||||
* Easily [override](./pkgs/override.nix) packages from different nixpkgs versions.
|
* Easily [override](./unstable/default.nix) packages from different nixpkgs
|
||||||
|
versions.
|
||||||
* Keep [user](./users) configuration isolated and easily reusable by taking
|
* Keep [user](./users) configuration isolated and easily reusable by taking
|
||||||
advantage of [user profiles](./users/profiles) and [home-manager][home-manager].
|
advantage of [user profiles](./users/profiles) and [home-manager][home-manager].
|
||||||
* [Overlay](./overlays) files are automatically available and sharable.
|
* [Overlay](./overlays) files are automatically available and sharable.
|
||||||
|
|
12
extern/default.nix
vendored
Normal file
12
extern/default.nix
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{ inputs }: with inputs;
|
||||||
|
{
|
||||||
|
modules = [
|
||||||
|
home.nixosModules.home-manager
|
||||||
|
ci-agent.nixosModules.agent-profile
|
||||||
|
];
|
||||||
|
|
||||||
|
overlays = [
|
||||||
|
nur.overlay
|
||||||
|
devshell.overlay
|
||||||
|
];
|
||||||
|
}
|
78
flake.nix
78
flake.nix
|
@ -26,37 +26,28 @@
|
||||||
, nixos-hardware
|
, nixos-hardware
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (builtins) attrValues;
|
|
||||||
inherit (flake-utils.lib) eachDefaultSystem flattenTreeSystem;
|
inherit (flake-utils.lib) eachDefaultSystem flattenTreeSystem;
|
||||||
inherit (nixos.lib) recursiveUpdate;
|
inherit (nixos.lib) recursiveUpdate;
|
||||||
inherit (self.lib) overlays nixosModules genPackages pkgImport
|
inherit (self.lib) overlays nixosModules genPackages genPkgs
|
||||||
genHomeActivationPackages;
|
genHomeActivationPackages;
|
||||||
|
|
||||||
externOverlays = [ nur.overlay devshell.overlay ];
|
extern = import ./extern { inherit inputs; };
|
||||||
externModules = [
|
|
||||||
home.nixosModules.home-manager
|
pkgs' = genPkgs { inherit self; };
|
||||||
ci-agent.nixosModules.agent-profile
|
|
||||||
];
|
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = self.legacyPackages.${system};
|
pkgs = pkgs'.${system};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit nixosModules overlays;
|
inherit nixosModules overlays;
|
||||||
|
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
import ./hosts
|
import ./hosts (recursiveUpdate inputs {
|
||||||
(recursiveUpdate inputs {
|
inherit pkgs system extern;
|
||||||
inherit pkgs externModules system;
|
inherit (pkgs) lib;
|
||||||
inherit (pkgs) lib;
|
});
|
||||||
});
|
|
||||||
|
|
||||||
homeConfigurations =
|
|
||||||
builtins.mapAttrs
|
|
||||||
(_: config: config.config.home-manager.users)
|
|
||||||
self.nixosConfigurations;
|
|
||||||
|
|
||||||
overlay = import ./pkgs;
|
overlay = import ./pkgs;
|
||||||
|
|
||||||
|
@ -68,50 +59,23 @@
|
||||||
|
|
||||||
defaultTemplate = self.templates.flk;
|
defaultTemplate = self.templates.flk;
|
||||||
};
|
};
|
||||||
in
|
|
||||||
recursiveUpdate
|
|
||||||
(eachDefaultSystem
|
|
||||||
(system:
|
|
||||||
let
|
|
||||||
unstable = pkgImport master [ ] system;
|
|
||||||
|
|
||||||
pkgs =
|
systemOutputs = eachDefaultSystem (system:
|
||||||
let
|
let pkgs = pkgs'.${system}; in
|
||||||
override = import ./pkgs/override.nix;
|
|
||||||
overlays = [
|
|
||||||
(override unstable)
|
|
||||||
self.overlay
|
|
||||||
(final: prev: {
|
|
||||||
lib = (prev.lib or { }) // {
|
|
||||||
inherit (nixos.lib) nixosSystem;
|
|
||||||
flk = self.lib;
|
|
||||||
utils = flake-utils.lib;
|
|
||||||
};
|
|
||||||
})
|
|
||||||
]
|
|
||||||
++ (attrValues self.overlays)
|
|
||||||
++ externOverlays;
|
|
||||||
in
|
|
||||||
pkgImport nixos overlays system;
|
|
||||||
|
|
||||||
packages =
|
|
||||||
flattenTreeSystem system
|
|
||||||
(genPackages {
|
|
||||||
inherit self pkgs;
|
|
||||||
});
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
inherit packages;
|
packages = flattenTreeSystem system
|
||||||
hmActivationPackages = genHomeActivationPackages
|
(genPackages {
|
||||||
self.homeConfigurations;
|
inherit self pkgs;
|
||||||
|
});
|
||||||
|
|
||||||
devShell = import ./shell {
|
devShell = import ./shell {
|
||||||
inherit pkgs nixos;
|
inherit pkgs nixos;
|
||||||
};
|
};
|
||||||
|
|
||||||
legacyPackages = pkgs;
|
legacyPackages.hmActivationPackages =
|
||||||
})
|
genHomeActivationPackages { inherit self; };
|
||||||
)
|
}
|
||||||
outputs;
|
);
|
||||||
|
in
|
||||||
|
recursiveUpdate outputs systemOutputs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
, pkgs
|
, pkgs
|
||||||
, self
|
, self
|
||||||
, system
|
, system
|
||||||
, externModules
|
, extern
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
@ -15,9 +15,6 @@ let
|
||||||
profiles = defaultImports (toString ../profiles);
|
profiles = defaultImports (toString ../profiles);
|
||||||
suites = import ../profiles/suites.nix { inherit lib profiles; };
|
suites = import ../profiles/suites.nix { inherit lib profiles; };
|
||||||
|
|
||||||
unstableModules = [ ];
|
|
||||||
addToDisabledModules = [ ];
|
|
||||||
|
|
||||||
config = hostName:
|
config = hostName:
|
||||||
nixosSystemExtended {
|
nixosSystemExtended {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
@ -33,12 +30,17 @@ let
|
||||||
let
|
let
|
||||||
core = profiles.core.default;
|
core = profiles.core.default;
|
||||||
|
|
||||||
modOverrides = { config, unstableModulesPath, ... }: {
|
modOverrides = { config, unstableModulesPath, ... }:
|
||||||
disabledModules = unstableModules ++ addToDisabledModules;
|
let
|
||||||
imports = map
|
unstable = import ../unstable;
|
||||||
(path: "${unstableModulesPath}/${path}")
|
inherit (unstable) modules disabledModules;
|
||||||
unstableModules;
|
in
|
||||||
};
|
{
|
||||||
|
disabledModules = modules ++ disabledModules;
|
||||||
|
imports = map
|
||||||
|
(path: "${unstableModulesPath}/${path}")
|
||||||
|
modules;
|
||||||
|
};
|
||||||
|
|
||||||
global = {
|
global = {
|
||||||
home-manager.useGlobalPkgs = true;
|
home-manager.useGlobalPkgs = true;
|
||||||
|
@ -80,7 +82,7 @@ let
|
||||||
global
|
global
|
||||||
local
|
local
|
||||||
modOverrides
|
modOverrides
|
||||||
] ++ externModules;
|
] ++ extern.modules;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,34 @@ in
|
||||||
|
|
||||||
overlays = pathsToImportedAttrs overlayPaths;
|
overlays = pathsToImportedAttrs overlayPaths;
|
||||||
|
|
||||||
|
genPkgs = { self }:
|
||||||
|
let inherit (self) inputs;
|
||||||
|
in
|
||||||
|
(inputs.flake-utils.lib.eachDefaultSystem
|
||||||
|
(system:
|
||||||
|
let
|
||||||
|
extern = import ../extern { inherit inputs; };
|
||||||
|
unstable = pkgImport inputs.master [ ] system;
|
||||||
|
overrides = (import ../unstable).packages;
|
||||||
|
|
||||||
|
overlays = [
|
||||||
|
(overrides unstable)
|
||||||
|
self.overlay
|
||||||
|
(final: prev: {
|
||||||
|
lib = (prev.lib or { }) // {
|
||||||
|
inherit (nixos.lib) nixosSystem;
|
||||||
|
flk = self.lib;
|
||||||
|
utils = inputs.flake-utils.lib;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]
|
||||||
|
++ (attrValues self.overlays)
|
||||||
|
++ extern.overlays;
|
||||||
|
in
|
||||||
|
{ pkgs = pkgImport nixos overlays system; }
|
||||||
|
)
|
||||||
|
).pkgs;
|
||||||
|
|
||||||
profileMap = map (profile: profile.default);
|
profileMap = map (profile: profile.default);
|
||||||
|
|
||||||
recImport = { dir, _import ? base: import "${dir}/${base}.nix" }:
|
recImport = { dir, _import ? base: import "${dir}/${base}.nix" }:
|
||||||
|
@ -135,7 +163,12 @@ in
|
||||||
in
|
in
|
||||||
recursiveUpdate cachixAttrs modulesAttrs;
|
recursiveUpdate cachixAttrs modulesAttrs;
|
||||||
|
|
||||||
genHomeActivationPackages = hmConfigs:
|
genHomeActivationPackages = { self }:
|
||||||
|
let hmConfigs =
|
||||||
|
builtins.mapAttrs
|
||||||
|
(_: config: config.config.home-manager.users)
|
||||||
|
self.nixosConfigurations;
|
||||||
|
in
|
||||||
mapAttrs
|
mapAttrs
|
||||||
(_: x: mapAttrs
|
(_: x: mapAttrs
|
||||||
(_: cfg: cfg.home.activationPackage)
|
(_: cfg: cfg.home.activationPackage)
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
# Packages inherited are imported in hosts/default.nix, and are pulled from
|
|
||||||
# nixpkgs master instead of the default nixos release. This doesn't actually
|
|
||||||
# install them, just creates an overlay to pull them from master if they are
|
|
||||||
# installed by the user elsewhere in the configuration.
|
|
||||||
pkgs: final: prev:
|
|
||||||
{
|
|
||||||
inherit (pkgs)
|
|
||||||
manix;
|
|
||||||
|
|
||||||
haskellPackages = prev.haskellPackages.override {
|
|
||||||
overrides = hfinal: hprev:
|
|
||||||
let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
# same for haskell packages, matching ghc versions
|
|
||||||
inherit (pkgs.haskell.packages."ghc${version}")
|
|
||||||
haskell-language-server;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -11,9 +11,6 @@ let
|
||||||
}).config.system.build;
|
}).config.system.build;
|
||||||
|
|
||||||
flk = pkgs.writeShellScriptBin "flk" ''
|
flk = pkgs.writeShellScriptBin "flk" ''
|
||||||
system="$(nix eval --impure --expr builtins.currentSystem)"
|
|
||||||
system="${"\${system//\\\"/"}}"
|
|
||||||
|
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
echo "Usage: $(basename $0) [ up | iso {host} | install {host} | {host} [switch|boot|test] | home {host} {user} [switch] ]"
|
echo "Usage: $(basename $0) [ up | iso {host} | install {host} | {host} [switch|boot|test] | home {host} {user} [switch] ]"
|
||||||
elif [[ "$1" == "up" ]]; then
|
elif [[ "$1" == "up" ]]; then
|
||||||
|
@ -31,7 +28,7 @@ let
|
||||||
elif [[ "$1" == "install" ]]; then
|
elif [[ "$1" == "install" ]]; then
|
||||||
sudo nixos-install --flake "$DEVSHELL_ROOT#$2" "${"\${@:3}"}"
|
sudo nixos-install --flake "$DEVSHELL_ROOT#$2" "${"\${@:3}"}"
|
||||||
elif [[ "$1" == "home" ]]; then
|
elif [[ "$1" == "home" ]]; then
|
||||||
nix build "./#hmActivationPackages.$system.$2.$3" "${"\${@:4}"}"
|
nix build "./#hmActivationPackages.$2.$3" "${"\${@:4}"}"
|
||||||
if [[ "$4" == "switch" ]]; then
|
if [[ "$4" == "switch" ]]; then
|
||||||
./result/activate && unlink result
|
./result/activate && unlink result
|
||||||
fi
|
fi
|
||||||
|
@ -50,8 +47,6 @@ pkgs.devshell.mkShell {
|
||||||
nixos-install
|
nixos-install
|
||||||
nixos-generate-config
|
nixos-generate-config
|
||||||
nixos-enter
|
nixos-enter
|
||||||
nixos-option
|
|
||||||
pre-commit
|
|
||||||
];
|
];
|
||||||
|
|
||||||
env = { inherit name; };
|
env = { inherit name; };
|
||||||
|
|
31
unstable/default.nix
Normal file
31
unstable/default.nix
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
# modules to pull from master, stable version is automatically disabled
|
||||||
|
modules = [ ];
|
||||||
|
|
||||||
|
# if a modules name changed in master, add the old name here
|
||||||
|
disabledModules = [ ];
|
||||||
|
|
||||||
|
# packages pulled from master
|
||||||
|
packages = pkgs: final: prev: {
|
||||||
|
inherit (pkgs)
|
||||||
|
dhall
|
||||||
|
discord
|
||||||
|
element-desktop
|
||||||
|
manix
|
||||||
|
nixpkgs-fmt
|
||||||
|
qutebrowser
|
||||||
|
signal-desktop
|
||||||
|
starship;
|
||||||
|
|
||||||
|
haskellPackages = prev.haskellPackages.override {
|
||||||
|
overrides = hfinal: hprev:
|
||||||
|
let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# same for haskell packages, matching ghc versions
|
||||||
|
inherit (pkgs.haskell.packages."ghc${version}")
|
||||||
|
haskell-language-server;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue