diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..96a56c1 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,119 @@ +{self, ...} @ inputs: +with inputs; let + ## Variable Declaration ## + # Supported Architectures + platforms = ["x86_64-linux"]; + + # NixOS Version + version = readFile ./.version; + + # System Libraries + inherit (self) files; + inherit (lib) eachSystem filters; + inherit (builtins) head readFile; + inherit (lib.util) build map pack; + lib = library.lib.extend (final: prev: + { + inherit (flatpak.lib) flatpak; + deploy = deploy.lib; + filters = ignore.lib // {inherit (filter.lib) filter matchExt;}; + hooks = hooks.lib; + image = generators.nixosGenerate; + wine = wine.lib; + util = import ./lib { + inherit self platforms; + lib = final; + }; + } + // home.lib + // utils.lib); +in + eachSystem platforms (system: let + # Default Package Channel + pkgs = self.legacyPackages."${system}"; + + # Package Calling Function + call = name: pkgs.callPackage name {inherit lib inputs pkgs files;}; + in { + ## Configuration Checks ## + checks = import ./modules/nix/checks.nix {inherit self system lib;}; + + ## Developer Shells ## + devShells = + map.modules' ./shells (file: pkgs.mkShell (import file pkgs)) + // { + default = import ./shells {inherit pkgs;}; + website = import ./site/shell.nix {inherit pkgs;}; + commit = + pkgs.mkShell {inherit (self.checks."${system}".commit) shellHook;}; + }; + + ## Code Formatter ## + formatter = pkgs.treefmt; + + ## Package Configuration ## + legacyPackages = self.channels."${system}".stable; + + # Channels + channels = { + stable = (build.channel stable [] ./packages/patches)."${system}"; + unstable = (build.channel unstable [nur.overlay] [])."${system}"; + wine = wine.packages."${system}"; + gaming = gaming.packages."${system}"; + apps = { + deploy = deploy.defaultPackage."${system}"; + generators = generators.defaultPackage."${system}"; + }; + }; + + # Custom Packages + # apps = map.modules ./scripts (name: lib.mkApp {drv = call name;}) // {default = self.apps."${system}".nixos;}; + # packages = map.modules ./packages call // map.modules ./scripts call // {default = self.packages."${system}".dotfiles;}; + }) + // { + # Overrides + overlays = map.modules ./packages/overlays import; + + ## Custom Library Functions ## + lib = lib.util; + + ## Program Configuration and 'dotfiles' ## + # files = import ./files lib self.legacyPackages."${head platforms}"; + + ## Custom Configuration Modules ## + nixosModules = + map.modules ./modules import + // {default = import ./modules {inherit version lib inputs files;};}; + + ## Configuration Templates ## + # templates = import ./.templates lib; + + ## Device Configuration ## + # deploy = import ./modules/nix/deploy.nix {inherit self lib;}; + # nixosConfigurations = + # map.modules ./devices (name: build.device (import name)); + + nixosConfigurations = { + Go3 = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ + ./hosts/WSL/Go3 + ]; + }; + StuPC = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ + ./hosts/WSL/StuPC + ]; + }; + + }; + + + ## Virtual Machines ## + # vmConfigurations = + # map.modules ./devices/vm (name: + # import name (head platforms) inputs self.channels."${head platforms}".stable); + + }; + } \ No newline at end of file diff --git a/flake.lock b/flake.lock index e138481..4f1a787 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "filter": { + "locked": { + "lastModified": 1676294984, + "narHash": "sha256-hdLUa/3RH1VJ+gMUysQE0JGM4F2Q/tIIFbtoxAOurJQ=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "fc282c5478e4141842f9644c239a41cfe9586732", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -46,6 +61,21 @@ "type": "github" } }, + "flake-utils_3": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -67,6 +97,43 @@ "type": "github" } }, + "ignore": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "library": { + "locked": { + "lastModified": 1674348806, + "narHash": "sha256-hKi7sFobRQg6sJxskRFCjt/d8gR+w0ClEWZatlr2rnw=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "af5239f892ae6e1c8bb560b11ed874cebbd10696", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "nixpkgs.lib", + "rev": "af5239f892ae6e1c8bb560b11ed874cebbd10696", + "type": "github" + } + }, "nixos-hardware": { "locked": { "lastModified": 1677440795, @@ -184,13 +251,17 @@ }, "root": { "inputs": { + "filter": "filter", "flake-utils": "flake-utils", "home-manager": "home-manager", + "ignore": "ignore", + "library": "library", "nixos-hardware": "nixos-hardware", "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "sops-nix": "sops-nix", + "utils": "utils_2", "vscode-server": "vscode-server" } }, @@ -228,6 +299,24 @@ "type": "github" } }, + "utils_2": { + "inputs": { + "flake-utils": "flake-utils_3" + }, + "locked": { + "lastModified": 1657226504, + "narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "type": "github" + } + }, "vscode-server": { "inputs": { "nixpkgs": "nixpkgs_3" diff --git a/flake.nix b/flake.nix index 122e5f8..9312f21 100644 --- a/flake.nix +++ b/flake.nix @@ -29,21 +29,34 @@ # homeage = {url = "github:jordanisaacs/homeage"; inputs.nixpkgs.follows = "nixpkgs";}; # Nix Library Functions - # library = { - # type = "github"; - # owner = "nix-community"; - # repo = "nixpkgs.lib"; - # ref = "master"; - # rev = "af5239f892ae6e1c8bb560b11ed874cebbd10696"; - # }; + library = { + type = "github"; + owner = "nix-community"; + repo = "nixpkgs.lib"; + ref = "master"; + rev = "af5239f892ae6e1c8bb560b11ed874cebbd10696"; + }; + # Source Filter Functions + filter.url = "github:numtide/nix-filter"; + ignore = { + url = "github:hercules-ci/gitignore.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # Flake Utility Functions + utils.url = "github:gytis-ivaskevicius/flake-utils-plus"; + }; - outputs = { self, nixpkgs, home-manager, ... }@inputs: + outputs = { self, nixpkgs, home-manager,library, ignore, filter,... }@inputs: let inherit (self) outputs; forEachSystem = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]; + platforms = ["x86_64-linux"]; + forEachPkgs = f: forEachSystem (sys: f nixpkgs.legacyPackages.${sys}); + in rec { packages = forEachPkgs (pkgs: import ./pkgs { inherit pkgs; }); @@ -51,7 +64,8 @@ overlays = import ./overlays { inherit inputs; }; nixosModules = import ./modules/nixos; homeManagerModules = import ./modules/home-manager; - # util = import ./lib/map.nix; + + util = import ./lib/map.nix; # NixOS configuration entrypoint # Available through 'nixos-rebuild --flake .#your-hostname' @@ -77,7 +91,7 @@ # FIXME replace with your username@hostname "sstent@Go3" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance - extraSpecialArgs = { inherit inputs outputs; }; + extraSpecialArgs = { inherit inputs outputs; hostName = "Go3"; }; modules = [ # > Our main home-manager configuration file < ./home-manager/users/sstent diff --git a/home-manager/global/keybase.nix b/home-manager/global/keybase.nix index ef48f19..0e5fd74 100644 --- a/home-manager/global/keybase.nix +++ b/home-manager/global/keybase.nix @@ -2,21 +2,21 @@ with lib; let - # inherit - # (builtins) + inherit + (builtins) # attrNames # attrValues # foldl' # isPath # pathExists - # readDir + readDir # toString - # ; + ; - # inherit - # (lib) + inherit + (lib) # flatten - # filterAttrs + filterAttrs # forEach # getAttrFromPath # hasPrefix @@ -27,26 +27,26 @@ let # mkIf # nameValuePair # removeSuffix - # ; + ; cfg = config.custom.keybase; username = config.home.username; secretstore = config._secretstore; -util = import "${inputs.self}/lib"; +# map = import "${inputs.self}/lib/map.nix"; - # # 'sops' Encrypted Secrets - # hm_secrets = dir: out_dir: - # filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: - # if type == "regular" - # then - # nameValuePair name { - # sopsFile = dir + "/${name}"; - # format = "binary"; - # path = out_dir + "/${name}"; + # 'sops' Encrypted Secrets + hm_secrets = dir: out_dir: + filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: + if type == "regular" + then + nameValuePair name { + sopsFile = dir + "/${name}"; + format = "binary"; + path = out_dir + "/${name}"; - # } - # else nameValuePair "" null) (readDir dir); + } + else nameValuePair "" null) (readDir dir); - # filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs); + filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs); in { @@ -70,7 +70,7 @@ in { systemd.user.services.kbfs.Unit.After = [ "sops-nix.service" ]; sops = { - secrets = util.map.hm_secrets "${secretstore}/user_dotfiles/${username}@${hostName}/keybase/" "${config.xdg.configHome}/keybase/"; + secrets = hm_secrets "${secretstore}/user_dotfiles/${username}@${hostName}/keybase/" "${config.xdg.configHome}/keybase/"; }; }; } diff --git a/secrets/user_dotfiles/sstent@go3/keybase/autostart_created b/secrets/user_dotfiles/sstent@Go3/keybase/autostart_created similarity index 100% rename from secrets/user_dotfiles/sstent@go3/keybase/autostart_created rename to secrets/user_dotfiles/sstent@Go3/keybase/autostart_created diff --git a/secrets/user_dotfiles/sstent@go3/keybase/config.json b/secrets/user_dotfiles/sstent@Go3/keybase/config.json similarity index 100% rename from secrets/user_dotfiles/sstent@go3/keybase/config.json rename to secrets/user_dotfiles/sstent@Go3/keybase/config.json diff --git a/secrets/user_dotfiles/sstent@go3/keybase/device_clone.json b/secrets/user_dotfiles/sstent@Go3/keybase/device_clone.json similarity index 100% rename from secrets/user_dotfiles/sstent@go3/keybase/device_clone.json rename to secrets/user_dotfiles/sstent@Go3/keybase/device_clone.json diff --git a/secrets/user_dotfiles/sstent@go3/keybase/gui_config.json b/secrets/user_dotfiles/sstent@Go3/keybase/gui_config.json similarity index 100% rename from secrets/user_dotfiles/sstent@go3/keybase/gui_config.json rename to secrets/user_dotfiles/sstent@Go3/keybase/gui_config.json diff --git a/secrets/user_dotfiles/sstent@go3/keybase/secretkeys.sstent.mpack b/secrets/user_dotfiles/sstent@Go3/keybase/secretkeys.sstent.mpack similarity index 100% rename from secrets/user_dotfiles/sstent@go3/keybase/secretkeys.sstent.mpack rename to secrets/user_dotfiles/sstent@Go3/keybase/secretkeys.sstent.mpack