mirror of
https://github.com/divnix/digga.git
synced 2024-12-25 00:55:08 +03:00
Merge pull request #42 from nrdxp/flake-clean
flake: clean up by moving implementation to utils
This commit is contained in:
commit
e7ce2fb21b
8
DOC.md
8
DOC.md
@ -74,8 +74,8 @@ directly from this flake via `nixosModules.cachix.<your-cachix>`.
|
||||
All expressions in both [modules/list.nix](modules/list.nix) and
|
||||
[pkgs/default.nix](pkgs/default.nix) are available globally, anywhere else in the
|
||||
repo. They are additionally included in the `nixosModules` and `overlay` flake
|
||||
outputs, respectively. Packages can manually be added to [flake.nix](flake.nix)
|
||||
for inclusion in the `packages` output as well.
|
||||
outputs, respectively. Packages are automatically included in the `packages`
|
||||
output as well.
|
||||
|
||||
The directory structure is identical to nixpkgs to provide a kind of staging area
|
||||
for any modules or packages we might be wanting to merge there later. If your not
|
||||
@ -88,4 +88,8 @@ line tools will be able to read overlays from here as well since it is set as
|
||||
`nixpkgs-overlays` in `NIX_PATH`. And of course they will be exported via the
|
||||
flake output `overlays` as well.
|
||||
|
||||
If you wish to use an overlay from an external flake, simply add it to the
|
||||
`externOverlays` list in the `let` block of the `outputs` attribute in
|
||||
[flake.nix](flake.nix).
|
||||
|
||||
[home-manager]: https://github.com/rycee/home-manager
|
||||
|
67
flake.nix
67
flake.nix
@ -13,76 +13,43 @@
|
||||
inherit (builtins) attrNames attrValues readDir;
|
||||
inherit (nixos) lib;
|
||||
inherit (lib) removeSuffix recursiveUpdate genAttrs filterAttrs;
|
||||
inherit (utils) pathsToImportedAttrs;
|
||||
inherit (utils) pathsToImportedAttrs genPkgset overlayPaths modules
|
||||
genPackages;
|
||||
|
||||
utils = import ./lib/utils.nix { inherit lib; };
|
||||
|
||||
system = "x86_64-linux";
|
||||
|
||||
pkgImport = pkgs:
|
||||
import pkgs {
|
||||
inherit system;
|
||||
overlays = attrValues self.overlays;
|
||||
config = { allowUnfree = true; };
|
||||
externOverlays = [ ];
|
||||
|
||||
pkgset =
|
||||
let overlays = (attrValues self.overlays) ++ externOverlays; in
|
||||
genPkgset {
|
||||
inherit master nixos overlays system;
|
||||
};
|
||||
|
||||
pkgset = {
|
||||
osPkgs = pkgImport nixos;
|
||||
pkgs = pkgImport master;
|
||||
};
|
||||
|
||||
in
|
||||
with pkgset;
|
||||
{
|
||||
nixosConfigurations =
|
||||
import ./hosts (recursiveUpdate inputs {
|
||||
inherit lib pkgset system utils;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
devShell."${system}" = import ./shell.nix {
|
||||
inherit pkgs;
|
||||
pkgs = osPkgs;
|
||||
};
|
||||
|
||||
overlay = import ./pkgs;
|
||||
|
||||
overlays =
|
||||
let
|
||||
overlayDir = ./overlays;
|
||||
fullPath = name: overlayDir + "/${name}";
|
||||
overlayPaths = map fullPath (attrNames (readDir overlayDir));
|
||||
in
|
||||
pathsToImportedAttrs overlayPaths;
|
||||
overlays = pathsToImportedAttrs overlayPaths;
|
||||
|
||||
packages."${system}" =
|
||||
let
|
||||
packages = self.overlay osPkgs osPkgs;
|
||||
overlays = lib.filterAttrs (n: v: n != "pkgs") self.overlays;
|
||||
overlayPkgs =
|
||||
genAttrs
|
||||
(attrNames overlays)
|
||||
(name: (overlays."${name}" osPkgs osPkgs)."${name}");
|
||||
in
|
||||
recursiveUpdate packages overlayPkgs;
|
||||
packages."${system}" = genPackages {
|
||||
overlay = self.overlay;
|
||||
overlays = self.overlays;
|
||||
pkgs = osPkgs;
|
||||
};
|
||||
|
||||
nixosModules =
|
||||
let
|
||||
# binary cache
|
||||
cachix = import ./cachix.nix;
|
||||
cachixAttrs = { inherit cachix; };
|
||||
|
||||
# modules
|
||||
moduleList = import ./modules/list.nix;
|
||||
modulesAttrs = pathsToImportedAttrs moduleList;
|
||||
|
||||
# profiles
|
||||
profilesList = import ./profiles/list.nix;
|
||||
profilesAttrs = { profiles = pathsToImportedAttrs profilesList; };
|
||||
|
||||
in
|
||||
recursiveUpdate
|
||||
(recursiveUpdate cachixAttrs modulesAttrs)
|
||||
profilesAttrs;
|
||||
nixosModules = modules;
|
||||
|
||||
templates.flk.path = ./.;
|
||||
templates.flk.description = "flk template";
|
||||
|
@ -11,7 +11,7 @@
|
||||
let
|
||||
inherit (utils) recImport;
|
||||
inherit (builtins) attrValues removeAttrs;
|
||||
inherit (pkgset) osPkgs pkgs;
|
||||
inherit (pkgset) osPkgs unstablePkgs;
|
||||
|
||||
config = hostName:
|
||||
lib.nixosSystem {
|
||||
@ -37,7 +37,7 @@ let
|
||||
"home-manager=${home}"
|
||||
];
|
||||
|
||||
nixpkgs = { pkgs = osPkgs; };
|
||||
nixpkgs.pkgs = osPkgs;
|
||||
|
||||
nix.registry = {
|
||||
master.flake = master;
|
||||
@ -52,7 +52,7 @@ let
|
||||
overrides = {
|
||||
nixpkgs.overlays =
|
||||
let
|
||||
override = import ../pkgs/override.nix pkgs;
|
||||
override = import ../pkgs/override.nix unstablePkgs;
|
||||
|
||||
overlay = pkg: final: prev: {
|
||||
"${pkg.pname}" = pkg;
|
||||
|
@ -2,7 +2,8 @@
|
||||
let
|
||||
inherit (builtins) attrNames isAttrs readDir listToAttrs;
|
||||
|
||||
inherit (lib) filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix;
|
||||
inherit (lib) filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix
|
||||
recursiveUpdate genAttrs;
|
||||
|
||||
# mapFilterAttrs ::
|
||||
# (name -> value -> bool )
|
||||
@ -13,21 +14,11 @@ let
|
||||
# Generate an attribute set by mapping a function over a list of values.
|
||||
genAttrs' = values: f: listToAttrs (map f values);
|
||||
|
||||
in
|
||||
{
|
||||
inherit mapFilterAttrs genAttrs';
|
||||
|
||||
recImport = { dir, _import ? base: import "${dir}/${base}.nix" }:
|
||||
mapFilterAttrs
|
||||
(_: v: v != null)
|
||||
(n: v:
|
||||
if n != "default.nix" && hasSuffix ".nix" n && v == "regular"
|
||||
then
|
||||
let name = removeSuffix ".nix" n; in nameValuePair (name) (_import name)
|
||||
|
||||
else
|
||||
nameValuePair ("") (null))
|
||||
(readDir dir);
|
||||
pkgImport = { pkgs, system, overlays }:
|
||||
import pkgs {
|
||||
inherit system overlays;
|
||||
config = { allowUnfree = true; };
|
||||
};
|
||||
|
||||
# Convert a list to file paths to attribute set
|
||||
# that has the filenames stripped of nix extension as keys
|
||||
@ -38,4 +29,68 @@ in
|
||||
value = import path;
|
||||
});
|
||||
|
||||
in
|
||||
{
|
||||
inherit mapFilterAttrs genAttrs' pkgImport pathsToImportedAttrs;
|
||||
|
||||
genPkgset = { master, nixos, overlays, system }:
|
||||
{
|
||||
osPkgs = pkgImport {
|
||||
inherit system overlays;
|
||||
pkgs = nixos;
|
||||
};
|
||||
|
||||
unstablePkgs = pkgImport {
|
||||
inherit system overlays;
|
||||
pkgs = master;
|
||||
};
|
||||
};
|
||||
|
||||
overlayPaths =
|
||||
let
|
||||
overlayDir = ../overlays;
|
||||
fullPath = name: overlayDir + "/${name}";
|
||||
in
|
||||
map fullPath (attrNames (readDir overlayDir));
|
||||
|
||||
recImport = { dir, _import ? base: import "${dir}/${base}.nix" }:
|
||||
mapFilterAttrs
|
||||
(_: v: v != null)
|
||||
(n: v:
|
||||
if n != "default.nix" && hasSuffix ".nix" n && v == "regular"
|
||||
then
|
||||
let name = removeSuffix ".nix" n; in nameValuePair (name) (_import name)
|
||||
else
|
||||
nameValuePair ("") (null))
|
||||
(readDir dir);
|
||||
|
||||
modules =
|
||||
let
|
||||
# binary cache
|
||||
cachix = import ../cachix.nix;
|
||||
cachixAttrs = { inherit cachix; };
|
||||
|
||||
# modules
|
||||
moduleList = import ../modules/list.nix;
|
||||
modulesAttrs = pathsToImportedAttrs moduleList;
|
||||
|
||||
# profiles
|
||||
profilesList = import ../profiles/list.nix;
|
||||
profilesAttrs = { profiles = pathsToImportedAttrs profilesList; };
|
||||
in
|
||||
recursiveUpdate
|
||||
(recursiveUpdate cachixAttrs modulesAttrs)
|
||||
profilesAttrs;
|
||||
|
||||
genPackages = { overlay, overlays, pkgs }:
|
||||
let
|
||||
packages = overlay pkgs pkgs;
|
||||
overlays' = lib.filterAttrs (n: v: n != "pkgs") overlays;
|
||||
overlayPkgs =
|
||||
genAttrs
|
||||
(attrNames overlays')
|
||||
(name: (overlays'."${name}" pkgs pkgs)."${name}");
|
||||
in
|
||||
recursiveUpdate packages overlayPkgs;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user