forked from pub-solar/os
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
|
@ -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
|
||||||
|
];
|
||||||
|
}
|
70
flake.nix
70
flake.nix
|
@ -26,38 +26,29 @@
|
||||||
, 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;
|
||||||
|
|
||||||
lib = import ./lib { inherit nixos; };
|
lib = import ./lib { inherit nixos; };
|
||||||
|
@ -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 = [
|
packages = flattenTreeSystem system
|
||||||
(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 {
|
(genPackages {
|
||||||
inherit self pkgs;
|
inherit self pkgs;
|
||||||
});
|
});
|
||||||
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit packages;
|
|
||||||
hmActivationPackages = genHomeActivationPackages
|
|
||||||
self.homeConfigurations;
|
|
||||||
|
|
||||||
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,11 +30,16 @@ let
|
||||||
let
|
let
|
||||||
core = profiles.core.default;
|
core = profiles.core.default;
|
||||||
|
|
||||||
modOverrides = { config, unstableModulesPath, ... }: {
|
modOverrides = { config, unstableModulesPath, ... }:
|
||||||
disabledModules = unstableModules ++ addToDisabledModules;
|
let
|
||||||
|
unstable = import ../unstable;
|
||||||
|
inherit (unstable) modules disabledModules;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
disabledModules = modules ++ disabledModules;
|
||||||
imports = map
|
imports = map
|
||||||
(path: "${unstableModulesPath}/${path}")
|
(path: "${unstableModulesPath}/${path}")
|
||||||
unstableModules;
|
modules;
|
||||||
};
|
};
|
||||||
|
|
||||||
global = {
|
global = {
|
||||||
|
@ -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