diff --git a/flake.nix b/flake.nix index 32b352d..aa3924a 100644 --- a/flake.nix +++ b/flake.nix @@ -44,41 +44,62 @@ }; - - outputs = { self, nixpkgs, home-manager, ignore, filter, library,... }@inputs: + outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, home-manager,... }: let - inherit (self) outputs; inherit (lib.my) mapModules mapModulesRec mapHosts; - forEachSystem = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]; - platforms = ["x86_64-linux"]; - forEachPkgs = f: forEachSystem (sys: f nixpkgs.legacyPackages.${sys}); + # outputs = { self, nixpkgs, home-manager, ignore, filter, library,... }@inputs: + system = "x86_64-linux"; + + mkPkgs = pkgs: extraOverlays: import pkgs { + inherit system; + config.allowUnfree = true; # forgive me Stallman senpai + overlays = extraOverlays ++ (lib.attrValues self.overlays); + }; + pkgs = mkPkgs nixpkgs [ self.overlay ]; + pkgs' = mkPkgs nixpkgs-unstable []; lib = nixpkgs.lib.extend - (self: super: { my = import ./lib { inherit nixpkgs inputs; lib = self; }; }); - - in - rec { - packages = forEachPkgs (pkgs: import ./pkgs { inherit pkgs; }); - devShells = forEachPkgs (pkgs: import ./shell.nix { inherit pkgs; }); - overlays = import ./overlays { inherit inputs; }; - nixosModules = import ./modules/nixos; - homeManagerModules = import ./modules/home-manager; - + (self: super: { my = import ./lib { inherit pkgs inputs; lib = self; }; }); + in { lib = lib.my; + overlay = + final: prev: { + unstable = pkgs'; + my = self.packages."${system}"; + }; + + overlays = + mapModules ./overlays import; + + packages."${system}" = + mapModules ./packages (p: pkgs.callPackage p {}); + + nixosModules = + { dotfiles = import ./.; } // mapModulesRec ./modules import; + + # packages = forEachPkgs (pkgs: import ./pkgs { inherit pkgs; }); + # devShells = forEachPkgs (pkgs: import ./shell.nix { inherit pkgs; }); + devShell."${system}" = + import ./shell.nix { inherit pkgs; }; + + # overlays = import ./overlays { inherit inputs; }; + # nixosModules = import ./modules/nixos; + homeManagerModules = import ./modules/home-manager; + # NixOS configuration entrypoint # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = { Go3 = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; + specialArgs = { inherit inputs ; }; modules = [ ./hosts/WSL/Go3 ]; }; StuPC = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; + specialArgs = { inherit inputs ; }; modules = [ ./hosts/WSL/StuPC ]; @@ -92,7 +113,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 lib; hostName = "Go3"; }; + extraSpecialArgs = { inherit inputs lib; hostName = "Go3"; }; modules = [ # > Our main home-manager configuration file < ./home-manager/users/sstent @@ -101,7 +122,7 @@ }; "sstent@StuPC" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance - extraSpecialArgs = { inherit inputs outputs; hostName = "StuPC";}; + extraSpecialArgs = { inherit inputs ; hostName = "StuPC";}; modules = [ # > Our main home-manager configuration file < ./home-manager/users/sstent diff --git a/lib/map.nix b/lib/map.nix index 4a4aa12..eeb039b 100644 --- a/lib/map.nix +++ b/lib/map.nix @@ -1,123 +1,123 @@ -{lib, ...}: let - inherit - (builtins) - attrNames - attrValues - foldl' - isPath - pathExists - readDir - toString - ; +# {lib, ...}: let +# inherit +# (builtins) +# attrNames +# attrValues +# foldl' +# isPath +# pathExists +# readDir +# toString +# ; - inherit - (lib) - flatten - filterAttrs - forEach - getAttrFromPath - hasPrefix - hasSuffix - id - mapAttrs' - mapAttrsToList - mkIf - nameValuePair - removeSuffix - ; -in rec { - ## Mapping Functions ## - array = list: func: forEach list (name: getAttrFromPath [name] func); - filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs); - list = func: foldl' (x: y: x + y + " ") "" (attrNames func); +# inherit +# (lib) +# flatten +# filterAttrs +# forEach +# getAttrFromPath +# hasPrefix +# hasSuffix +# id +# mapAttrs' +# mapAttrsToList +# mkIf +# nameValuePair +# removeSuffix +# ; +# in rec { +# ## Mapping Functions ## +# array = list: func: forEach list (name: getAttrFromPath [name] func); +# filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs); +# list = func: foldl' (x: y: x + y + " ") "" (attrNames func); - ## Files Map - # Top Level - files = dir: func: extension: - filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: let - path = "${toString dir}/${name}"; - in - if - (type == "directory" || type == "symlink") - && ( - if (extension == ".nix") - then pathExists "${path}/default.nix" - else true - ) - then nameValuePair name (func path) - else if - type - == "regular" - && ( - if (extension == ".nix") - then name != "default.nix" - else true - ) - && hasSuffix extension name - then nameValuePair (removeSuffix extension name) (func path) - else nameValuePair "" null) (readDir dir); +# ## Files Map +# # Top Level +# files = dir: func: extension: +# filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: let +# path = "${toString dir}/${name}"; +# in +# if +# (type == "directory" || type == "symlink") +# && ( +# if (extension == ".nix") +# then pathExists "${path}/default.nix" +# else true +# ) +# then nameValuePair name (func path) +# else if +# type +# == "regular" +# && ( +# if (extension == ".nix") +# then name != "default.nix" +# else true +# ) +# && hasSuffix extension name +# then nameValuePair (removeSuffix extension name) (func path) +# else nameValuePair "" null) (readDir dir); - # Recursive - files' = dir: func: extension: - filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: let - path = "${toString dir}/${name}"; - in - if (type == "directory" || type == "symlink") - then nameValuePair name (files' path func) - else if - type - == "regular" - && ( - if (extension == ".nix") - then name != "default.nix" - else true - ) - && hasSuffix extension name - then nameValuePair (removeSuffix extension name) (func path) - else nameValuePair "" null) (readDir dir); +# # Recursive +# files' = dir: func: extension: +# filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: let +# path = "${toString dir}/${name}"; +# in +# if (type == "directory" || type == "symlink") +# then nameValuePair name (files' path func) +# else if +# type +# == "regular" +# && ( +# if (extension == ".nix") +# then name != "default.nix" +# else true +# ) +# && hasSuffix extension name +# then nameValuePair (removeSuffix extension name) (func path) +# else nameValuePair "" null) (readDir dir); - # Package Patches - patches = patch: - if isPath patch - then - flatten (mapAttrsToList (name: type: - if - type - == "regular" - && (hasSuffix ".diff" name || hasSuffix ".patch" name) - then patch + "/${name}" - else null) (readDir patch)) - else patch; +# # Package Patches +# patches = patch: +# if isPath patch +# then +# flatten (mapAttrsToList (name: type: +# if +# type +# == "regular" +# && (hasSuffix ".diff" name || hasSuffix ".patch" name) +# then patch + "/${name}" +# else null) (readDir patch)) +# else patch; - # Module Imports - module = dir: attrValues (modules dir id); - module' = dir: attrNames (modules dir id); - modules = dir: func: files dir func ".nix"; - modules' = dir: func: files' dir func ".nix"; +# # Module Imports +# module = dir: attrValues (modules dir id); +# module' = dir: attrNames (modules dir id); +# modules = dir: func: files dir func ".nix"; +# modules' = dir: func: files' dir func ".nix"; - # 'sops' Encrypted Secrets - secrets = dir: neededForUsers: - filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: - if type == "regular" && hasSuffix ".secret" name - then - nameValuePair name { - sopsFile = dir + "/${name}"; - format = "binary"; - inherit neededForUsers; - } - else nameValuePair "" null) (readDir dir); +# # 'sops' Encrypted Secrets +# secrets = dir: neededForUsers: +# filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: +# if type == "regular" && hasSuffix ".secret" name +# then +# nameValuePair name { +# sopsFile = dir + "/${name}"; +# format = "binary"; +# inherit neededForUsers; +# } +# else nameValuePair "" null) (readDir dir); - # 'sops' Encrypted Secrets - hm_secrets = dir: out_dir: - filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: - if type == "regular" && hasSuffix ".age" name - 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" && hasSuffix ".age" name +# then +# nameValuePair name { +# sopsFile = dir + "/${name}"; +# format = "binary"; +# path = out_dir + "/${name}"; - } - else nameValuePair "" null) (readDir dir); -} \ No newline at end of file +# } +# else nameValuePair "" null) (readDir dir); +# } \ No newline at end of file