-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{system ? builtins.currentSystem}: let | ||
# Import nixpkgs and dream2nix | ||
helpers = import ./helpers.nix {inherit system;}; | ||
inherit (helpers) importNgiPackages pkgs; | ||
ngiPackages = importNgiPackages pkgs; | ||
in | ||
ngiPackages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{system ? builtins.currentSystem}: let | ||
lock = builtins.fromJSON (builtins.readFile ./flake.lock); | ||
|
||
# Import flake inputs using flake-compat from dream2nix | ||
flake = let | ||
dream2nix = with lock.nodes.dream2nix.locked; | ||
fetchTarball { | ||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; | ||
sha256 = narHash; | ||
}; | ||
in | ||
import (dream2nix + "/dev-flake/flake-compat.nix") { | ||
inherit system; | ||
src = ./.; | ||
}; | ||
in | ||
flake.defaultNix.inputs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
system ? builtins.currentSystem, | ||
inputs ? import ./flake-inputs.nix {inherit system;}, | ||
nixpkgs ? inputs.nixpkgs, | ||
dream2nix ? inputs.dream2nix, | ||
sops-nix ? inputs.sops-nix, | ||
}: let | ||
pkgs = import nixpkgs.outPath {inherit system;}; | ||
|
||
lib = pkgs.lib.recursiveUpdate pkgs.lib (import ./lib.nix {inherit (pkgs) lib;}); | ||
|
||
helpers = rec { | ||
# NGI packages are imported from ./pkgs/by-name/default.nix. | ||
importNgiPackages = pkgs: let | ||
callPackage = pkgs.newScope ( | ||
ngiPackages // {inherit callPackage;} | ||
); | ||
|
||
ngiPackages = import ./pkgs/by-name { | ||
inherit (pkgs) lib; | ||
inherit callPackage pkgs; | ||
dream2nix = import dream2nix.outPath {inherit pkgs;}; | ||
}; | ||
in | ||
ngiPackages; | ||
|
||
# NGI projects are imported from ./projects/default.nix. | ||
# Each project includes packages, and optionally, modules, configurations and tests. | ||
importNgiProjects = pkgs: let | ||
ngiProjects = import ./projects { | ||
inherit lib pkgs; | ||
sources = { | ||
configurations = rawNixosConfigurations; | ||
modules = extendedNixosModules; | ||
}; | ||
}; | ||
in | ||
ngiProjects; | ||
|
||
# The above definition reimports `rawNixosConfigurations` and `extendedNixosModules` into `sources`. | ||
# As configurations and modules are system-agnostic, they are defined by passing `{}` to `importNgiProjects`. | ||
rawNgiProjects = importNgiProjects {}; | ||
|
||
rawNixosConfigurations = lib.flattenAttrsSlash (lib.mapAttrs (_: v: lib.mapAttrs (_: v: v.path) v) ( | ||
lib.mapAttrByPath ["nixos" "configurations"] {} rawNgiProjects | ||
)); | ||
|
||
rawNixosModules = lib.flattenAttrsDot (lib.foldl lib.recursiveUpdate {} (lib.attrValues ( | ||
lib.mapAttrByPath ["nixos" "modules"] {} rawNgiProjects | ||
))); | ||
|
||
rawOutputs = rec { | ||
nixosModules = | ||
{ | ||
unbootable = ./modules/unbootable.nix; | ||
# The default module adds the default overlay on top of Nixpkgs. | ||
# This is so that `ngipkgs` can be used alongside `nixpkgs` in a configuration. | ||
default.nixpkgs.overlays = [overlays.default]; | ||
} | ||
// (lib.filterAttrs (_: v: v != null) rawNixosModules); | ||
|
||
overlays.default = final: prev: importNgiPackages prev; | ||
}; | ||
|
||
extendedNixosModules = | ||
rawOutputs.nixosModules | ||
// { | ||
sops-nix = sops-nix.nixosModules.default; | ||
}; | ||
|
||
extendedNixosConfigurations = | ||
lib.mapAttrs | ||
(_: config: lib.nixosSystem {modules = [config ./dummy.nix] ++ lib.attrValues extendedNixosModules;}) | ||
rawNixosConfigurations; | ||
}; | ||
in | ||
helpers // {inherit inputs pkgs;} |