···55 # we want to track changes here, and reaload the environment
66 # we choose these files because they are the ones that are most likely
77 # to have made a change that required a shell reaload
88- watch_dir modules/flake/programs
99- watch_file modules/flake/args.nix
88+ watch_file modules/flake/programs/shell.nix
99+ watch_file modules/flake/programs/formatter.nix
10101111 # now we want to load the flake environment
1212 use flake
···11-{ inputs, ... }:
22-{
33- # set the output systems for this flake
44- systems = [
55- "x86_64-linux"
66- "aarch64-linux"
77- "aarch64-darwin"
88- ];
99-1010- perSystem =
1111- { system, ... }:
1212- {
1313- # this is what controls how packages in the flake are built, but this is not passed to the
1414- # builders in lib which is important to note, since we have to do something different for
1515- # the builders to work correctly
1616- _module.args.pkgs = import inputs.nixpkgs {
1717- inherit system;
1818- config = {
1919- allowUnfree = true;
2020- allowUnsupportedSystem = true;
2121- };
2222- overlays = [ ];
2323- };
2424- };
2525-}
+19-7
modules/flake/checks/default.nix
···11-{
22- imports = [
33- # keep-sorted start
44- ./formatting.nix
55- ./lib.nix
11+# I would highly advise you do not use my flake as an input and instead you vendor this
22+# if you want to use this code.
33+{ pkgs, inputs, ... }:
44+55+let
66+ inherit (pkgs) lib;
77+88+ scope = pkgs.lib.makeScope pkgs.newScope (scopeSelf: {
99+ inherit (inputs) self;
1010+1111+ # keep-sorted start block=yes newline_separated=yes
1212+ formatting = scopeSelf.callPackage ./formatting.nix { };
1313+1414+ # lib = scopeSelf.callPackage ./lib.nix { };
615 # keep-sorted end
77- ];
88-}
1616+ });
1717+1818+in
1919+2020+lib.filterAttrs (_: lib.isDerivation) scope
···11+inputs:
22+33+let
44+55+ inherit (inputs) nixpkgs self;
66+ inherit (nixpkgs) lib;
77+88+ systems = [
99+ "x86_64-linux"
1010+ "aarch64-linux"
1111+ "aarch64-darwin"
1212+ ];
1313+1414+ forAllSystems = fn: lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system});
1515+1616+ mkHosts = lib.mapAttrs self.lib.mkHost;
1717+in
1818+119{
22- imports = [
33- # keep-sorted start prefix_order=../../,./
44- ../../systems
55- ./args.nix # the base args that is passed to the flake
66- ./checks # custom checks that are devised to test if the system is working as expected
77- ./lib # the lib that is used in the system
88- ./packages # our custom packages provided by the flake
99- ./programs # programs that run in the dev shell
2020+ # a raw unfilted scope of packages
2121+ legacyPackages = forAllSystems (pkgs: import ./packages { inherit pkgs inputs; });
2222+2323+ packages = forAllSystems (
2424+ pkgs:
2525+ lib.filterAttrs (
2626+ _: pkg:
2727+ let
2828+ isDerivation = lib.isDerivation pkg;
2929+ availableOnHost = lib.meta.availableOn pkgs.stdenv.hostPlatform pkg;
3030+ isBroken = pkg.meta.broken or false;
3131+ in
3232+ isDerivation && !isBroken && availableOnHost
3333+ ) self.legacyPackages.${pkgs.stdenv.hostPlatform.system}
3434+ );
3535+3636+ # get a list of packages for the host system, and if none exist use an empty set
3737+ overlays.default = _: prev: self.packages.${prev.stdenv.hostPlatform.system} or { };
3838+3939+ devShells = forAllSystems (pkgs: {
4040+ default = pkgs.callPackage ./programs/shell.nix {
4141+ treefmt-wrapped = self.formatter.${pkgs.stdenv.hostPlatform.system};
4242+ };
4343+ });
4444+4545+ lib = import ./lib { inherit lib inputs; };
4646+4747+ checks = forAllSystems (pkgs: import ./checks { inherit pkgs inputs; });
4848+4949+ formatter = forAllSystems (pkgs: pkgs.callPackage ./programs/formatter.nix { });
5050+5151+ # This is the list of system configuration
5252+ #
5353+ # the defaults consists of the following:
5454+ # arch = "x86_64";
5555+ # class = "nixos";
5656+ # modules = [ ];
5757+ # specialArgs = { };
5858+ nixosConfigurations = mkHosts {
5959+ # keep-sorted start block=yes newline_separated=yes
6060+ amaterasu = { };
6161+6262+ aphrodite = { };
6363+6464+ athena = { };
6565+6666+ hephaestus = { };
6767+6868+ isis = { };
6969+7070+ lilith = {
7171+ class = "iso";
7272+ };
7373+7474+ minerva = { };
7575+7676+ skadi = {
7777+ arch = "aarch64";
7878+ };
7979+8080+ valkyrie = {
8181+ class = "wsl";
8282+ };
1083 # keep-sorted end
1111- ];
8484+ };
8585+8686+ darwinConfigurations = mkHosts {
8787+ # keep-sorted start block=yes newline_separated=yes
8888+ tatsumaki = {
8989+ arch = "aarch64";
9090+ class = "darwin";
9191+ };
9292+ #keep-sorted end
9393+ };
1294}
+35-39
modules/flake/lib/default.nix
···11# following https://github.com/NixOS/nixpkgs/blob/77ee426a4da240c1df7e11f48ac6243e0890f03e/lib/default.nix
22# as a rough template we can create our own extensible lib and expose it to the flake
33# we can then use that elsewhere like our hosts
44-{ lib, inputs, ... }:
55-let
66- gardenLib = lib.fixedPoints.makeExtensible (final: {
77- # keep-sorted start block=yes
88- hardware = import ./hardware.nix;
99- helpers = import ./helpers.nix { inherit lib; };
1010- secrets = import ./secrets.nix { inherit inputs; };
1111- services = import ./services.nix { inherit lib; };
1212- template = import ./template; # templates, selections of code that are repeated
1313- validators = import ./validators.nix { inherit lib; };
1414- # keep-sorted end
44+{ lib, inputs }:
1551616- # we have to rexport the functions we want to use, but don't want to refer to the whole lib
1717- # "path". e.g. gardenLib.hardware.isx86Linux can be shortened to gardenLib.isx86Linux
1818- # NOTE: never rexport templates
1919- inherit (final.hardware) isx86Linux ldTernary;
2020- inherit (final.helpers)
2121- mkPubs
2222- giturl
2323- filterNixFiles
2424- importNixFiles
2525- importNixFilesAndDirs
2626- boolToNum
2727- containsStrings
2828- indexOf
2929- intListToStringList
3030- ;
3131- inherit (final.secrets) mkSecret;
3232- inherit (final.services) mkGraphicalService mkServiceOption;
3333- inherit (final.validators)
3434- ifTheyExist
3535- ifOneEnabled
3636- anyHome
3737- ;
3838- });
3939-in
4040-{
4141- # expose our custom lib to the flake
4242- flake.lib = gardenLib;
4343-}
66+lib.fixedPoints.makeExtensible (final: {
77+ # keep-sorted start block=yes
88+ hardware = import ./hardware.nix;
99+ helpers = import ./helpers.nix { inherit lib; };
1010+ mkHost = import ./mkhost.nix { inherit inputs lib; };
1111+ secrets = import ./secrets.nix { inherit inputs; };
1212+ services = import ./services.nix { inherit lib; };
1313+ template = import ./template; # templates, selections of code that are repeated
1414+ validators = import ./validators.nix { inherit lib; };
1515+ # keep-sorted end
1616+1717+ # we have to rexport the functions we want to use, but don't want to refer to the whole lib
1818+ # "path". e.g. gardenLib.hardware.isx86Linux can be shortened to gardenLib.isx86Linux
1919+ # NOTE: never rexport templates
2020+ inherit (final.hardware) isx86Linux ldTernary;
2121+ inherit (final.helpers)
2222+ mkPubs
2323+ giturl
2424+ filterNixFiles
2525+ importNixFiles
2626+ importNixFilesAndDirs
2727+ boolToNum
2828+ containsStrings
2929+ indexOf
3030+ intListToStringList
3131+ ;
3232+ inherit (final.secrets) mkSecret;
3333+ inherit (final.services) mkGraphicalService mkServiceOption;
3434+ inherit (final.validators)
3535+ ifTheyExist
3636+ ifOneEnabled
3737+ anyHome
3838+ ;
3939+})
+153
modules/flake/lib/mkhost.nix
···11+{
22+ lib,
33+ inputs,
44+}:
55+let
66+ inherit (inputs) self;
77+88+ inherit (lib)
99+ optionals
1010+ singleton
1111+ concatLists
1212+ recursiveUpdate
1313+ mapAttrs
1414+ ;
1515+in
1616+/**
1717+ mkHost is a function that uses withSystem to give us inputs' and self'
1818+ it also assumes the the system type either nixos or darwin and uses the appropriate
1919+2020+ # Type
2121+2222+ ```
2323+ mkHost :: String -> AttrSet -> AttrSet
2424+ ```
2525+2626+ # Example
2727+2828+ ```nix
2929+ mkHost "myhost" {
3030+ arch = "x86_64";
3131+ class = "nixos";
3232+ modules = [ ./module.nix ];
3333+ specialArgs = { foo = "bar"; };
3434+ }
3535+ ```
3636+*/
3737+name:
3838+{
3939+ arch ? "x86_64",
4040+ class ? "nixos",
4141+ modules ? [ ],
4242+ specialArgs ? { },
4343+ ...
4444+}:
4545+let
4646+ inherit (inputs) darwin nixpkgs;
4747+4848+ os =
4949+ {
5050+ iso = "linux";
5151+ wsl = "linux";
5252+ nixos = "linux";
5353+ }
5454+ .${class} or class;
5555+ system = "${arch}-${os}";
5656+5757+ evalHost = if class == "darwin" then darwin.lib.darwinSystem else nixpkgs.lib.nixosSystem;
5858+in
5959+evalHost {
6060+ # we use recursiveUpdate such that users can "override" the specialArgs
6161+ #
6262+ # This should only be used for special arguments that need to be evaluated
6363+ # when resolving module structure (like in imports).
6464+ specialArgs = recursiveUpdate {
6565+ inherit
6666+ # these are normal args that people expect to be passed,
6767+ # but we expect to be evaluated when resolving module structure
6868+ inputs
6969+7070+ # even though self is just the same as `inputs.self`
7171+ # we still pass this as some people will use this
7272+ self
7373+ ;
7474+ } specialArgs;
7575+7676+ modules = concatLists [
7777+ [
7878+ # import our host system paths
7979+ "${self}/systems/${name}/default.nix"
8080+8181+ # import the files required for the class
8282+ "${self}/modules/${class}/default.nix"
8383+ ]
8484+8585+ # get an installer profile from nixpkgs to base the Isos off of
8686+ # this is useful because it makes things alot easier
8787+ (optionals (class == "iso") [
8888+ "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix"
8989+ ])
9090+9191+ # the next 3 singleton's are split up to make it easier to understand as they do things different things
9292+9393+ # recall `specialArgs` would take be preferred when resolving module structure
9494+ # well this is how we do it use it for all args that don't need to rosolve module structure
9595+ (singleton (
9696+ { config, ... }:
9797+ let
9898+ inputs' = mapAttrs (_: mapAttrs (_: v: v.${config.nixpkgs.hostPlatform.system} or v)) inputs;
9999+ in
100100+ {
101101+ key = "dotfiles#specialArgs";
102102+ _file = "${__curPos.file}";
103103+104104+ _module.args = {
105105+ inherit inputs';
106106+ self' = inputs'.self;
107107+ };
108108+ }
109109+ ))
110110+111111+ # here we make some basic assumptions about the system the person is using
112112+ # like the system type and the hostname
113113+ (singleton {
114114+ key = "dotfiles#hostname";
115115+ _file = "${__curPos.file}";
116116+117117+ # we set the systems hostname based on the host value
118118+ # which should be a string that is the hostname of the system
119119+ networking.hostName = name;
120120+ })
121121+122122+ (singleton {
123123+ key = "dotfiles#nixpkgs";
124124+ _file = "${__curPos.file}";
125125+126126+ nixpkgs = {
127127+ # you can also do this as `inherit system;` with the normal `lib.nixosSystem`
128128+ # however for evalModules this will not work, so we do this instead
129129+ hostPlatform = system;
130130+131131+ # The path to the nixpkgs sources used to build the system.
132132+ # This is automatically set up to be the store path of the nixpkgs flake used to build
133133+ # the system if using lib.nixosSystem, and is otherwise null by default.
134134+ # so that means that we should set it to our nixpkgs flake output path
135135+ flake.source = nixpkgs.outPath;
136136+ };
137137+ })
138138+139139+ # if we are on darwin we need to import the nixpkgs source, its used in some
140140+ # modules, if this is not set then you will get an error
141141+ (optionals (class == "darwin") (singleton {
142142+ key = "dotfiles#nixpkgs-darwin";
143143+ _file = "${__curPos.file}";
144144+145145+ # without supplying an upstream nixpkgs source, nix-darwin will not be able to build
146146+ # and will complain and log an error demanding that you must set this value
147147+ nixpkgs.source = nixpkgs;
148148+ }))
149149+150150+ # import any additional modules that the user has provided
151151+ modules
152152+ ];
153153+}
+12-36
modules/flake/packages/default.nix
···11# I would highly advise you do not use my flake as an input and instead you vendor this
22-# if you want to use this code, you may want to add my cachix cache to your flake
33-# you may want to not have to build this for yourself however
44-{ lib, inputs, ... }:
55-{
66- # get a list of packages for the host system, and if none exist use an empty set
77- flake.overlays.default = _: prev: inputs.self.packages.${prev.stdenv.hostPlatform.system} or { };
88-99- perSystem =
1010- {
1111- pkgs,
1212- inputs',
1313- ...
1414- }:
1515- let
1616- packages = lib.makeScope pkgs.newScope (self: {
1717- inherit inputs;
22+# if you want to use this code.
33+{ pkgs, inputs, ... }:
1841919- # keep-sorted start block=yes newline_separated=yes
2020- docs = self.callPackage ./docs/package.nix { };
55+pkgs.lib.makeScope pkgs.newScope (self: {
66+ inherit inputs;
2172222- iztaller = self.callPackage ./iztaller/package.nix { nix = inputs'.izlix.packages.lix; };
88+ # keep-sorted start block=yes newline_separated=yes
99+ docs = self.callPackage ./docs/package.nix { };
23102424- libdoc = self.callPackage ./docs/lib.nix { };
2525- # keep-sorted end
2626- });
2727- in
2828- {
2929- legacyPackages = packages;
1111+ iztaller = self.callPackage ./iztaller/package.nix {
1212+ nix = inputs.izlix.packages.${pkgs.stdenv.hostPlatform.system}.lix;
1313+ };
30143131- packages = lib.filterAttrs (
3232- _: pkg:
3333- let
3434- isDerivation = lib.isDerivation pkg;
3535- availableOnHost = lib.meta.availableOn pkgs.stdenv.hostPlatform pkg;
3636- isBroken = pkg.meta.broken or false;
3737- in
3838- isDerivation && !isBroken && availableOnHost
3939- ) packages;
4040- };
4141-}
1515+ libdoc = self.callPackage ./docs/lib.nix { };
1616+ # keep-sorted end
1717+})
-8
modules/flake/programs/default.nix
···11-{
22- imports = [
33- # keep-sorted start
44- ./formatter.nix # formatter for nix fmt, via treefmt is a formatter for every language
55- ./shell.nix # a dev shell that provieds all that you will need to work
66- # keep-sorted end
77- ];
88-}
···11-{ self, inputs, ... }:
22-{
33- imports = [ inputs.easy-hosts.flakeModule ];
44-55- config.easy-hosts = {
66- additionalClasses = {
77- wsl = "nixos";
88- };
99-1010- perClass = class: {
1111- modules = [
1212- # import the class module, this contains the common configurations between all systems of the same class
1313- "${self}/modules/${class}/default.nix"
1414- ];
1515- };
1616-1717- # This is the list of system configuration
1818- #
1919- # the defaults consists of the following:
2020- # arch = "x86_64";
2121- # class = "nixos";
2222- # modules = [ ];
2323- # specialArgs = { };
2424- hosts = {
2525- # keep-sorted start block=yes newline_separated=yes
2626- amaterasu = { };
2727-2828- aphrodite = { };
2929-3030- athena = { };
3131-3232- hephaestus = { };
3333-3434- isis = { };
3535-3636- lilith = {
3737- class = "iso";
3838- };
3939-4040- minerva = { };
4141-4242- skadi = {
4343- arch = "aarch64";
4444- };
4545-4646- tatsumaki = {
4747- arch = "aarch64";
4848- class = "darwin";
4949- };
5050-5151- valkyrie = {
5252- class = "wsl";
5353- };
5454- # keep-sorted end
5555- };
5656- };
5757-}
-1
systems/lilith/README.md
···11-Most the code from here has been refactored out into [the iso module](../../modules/iso) this directory still exists in case I need to add more isos or specific overrides.
+4
systems/lilith/default.nix
···11+# Most the code from here has been refactored out into [the iso
22+# module](../../modules/iso) this directory still exists in case I need to add
33+# more isos or specific overrides.
44+{ }