This commit is contained in:
2023-02-28 14:01:36 +00:00
parent 8db4eaaacf
commit 1b8c106166
5 changed files with 219 additions and 166 deletions

34
flake.lock generated
View File

@@ -61,6 +61,21 @@
"type": "github" "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": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -246,6 +261,7 @@
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",
"utils": "utils_2",
"vscode-server": "vscode-server" "vscode-server": "vscode-server"
} }
}, },
@@ -283,6 +299,24 @@
"type": "github" "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": { "vscode-server": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_3"

View File

@@ -28,6 +28,7 @@
vscode-server.url = "github:msteen/nixos-vscode-server"; vscode-server.url = "github:msteen/nixos-vscode-server";
# homeage = {url = "github:jordanisaacs/homeage"; inputs.nixpkgs.follows = "nixpkgs";}; # homeage = {url = "github:jordanisaacs/homeage"; inputs.nixpkgs.follows = "nixpkgs";};
# Nix Library Functions
library = { library = {
type = "github"; type = "github";
owner = "nix-community"; owner = "nix-community";
@@ -35,71 +36,47 @@
ref = "master"; ref = "master";
rev = "af5239f892ae6e1c8bb560b11ed874cebbd10696"; rev = "af5239f892ae6e1c8bb560b11ed874cebbd10696";
}; };
# Source Filter Functions
filter.url = "github:numtide/nix-filter"; filter.url = "github:numtide/nix-filter";
ignore = { ignore = {
url = "github:hercules-ci/gitignore.nix"; url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
# Flake Utility Functions
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
}; };
outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, home-manager,... }:
outputs = { self, nixpkgs, home-manager,library, ignore, filter,... }@inputs:
let let
inherit (lib.my) mapModules mapModulesRec mapHosts; inherit (self) outputs;
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: in
system = "x86_64-linux"; rec {
packages = forEachPkgs (pkgs: import ./pkgs { inherit pkgs; });
mkPkgs = pkgs: extraOverlays: import pkgs { devShells = forEachPkgs (pkgs: import ./shell.nix { inherit pkgs; });
inherit system; overlays = import ./overlays { inherit inputs; };
config.allowUnfree = true; # forgive me Stallman senpai nixosModules = import ./modules/nixos;
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 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; homeManagerModules = import ./modules/home-manager;
# NixOS configuration entrypoint # NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname' # Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = { nixosConfigurations = {
Go3 = nixpkgs.lib.nixosSystem { Go3 = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs ; }; specialArgs = { inherit inputs outputs; };
modules = [ modules = [
./hosts/WSL/Go3 ./hosts/WSL/Go3
]; ];
}; };
StuPC = nixpkgs.lib.nixosSystem { StuPC = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs ; }; specialArgs = { inherit inputs outputs; };
modules = [ modules = [
./hosts/WSL/StuPC ./hosts/WSL/StuPC
]; ];
@@ -113,7 +90,7 @@
# FIXME replace with your username@hostname # FIXME replace with your username@hostname
"sstent@Go3" = home-manager.lib.homeManagerConfiguration { "sstent@Go3" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs lib; hostName = "Go3"; }; extraSpecialArgs = { inherit inputs outputs; hostName = "Go3"; };
modules = [ modules = [
# > Our main home-manager configuration file < # > Our main home-manager configuration file <
./home-manager/users/sstent ./home-manager/users/sstent
@@ -122,7 +99,7 @@
}; };
"sstent@StuPC" = home-manager.lib.homeManagerConfiguration { "sstent@StuPC" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs ; hostName = "StuPC";}; extraSpecialArgs = { inherit inputs outputs; hostName = "StuPC";};
modules = [ modules = [
# > Our main home-manager configuration file < # > Our main home-manager configuration file <
./home-manager/users/sstent ./home-manager/users/sstent

View File

@@ -1,11 +1,53 @@
{ config, pkgs, lib, inputs, hostName, outputs, ... }: { config, pkgs, inputs, lib, hostName, util, ... }:
with lib; with lib;
with lib.my;
let let
inherit
(builtins)
# attrNames
# attrValues
# foldl'
# isPath
# pathExists
readDir
# toString
;
inherit
(lib)
# flatten
filterAttrs
# forEach
# getAttrFromPath
# hasPrefix
# hasSuffix
# id
# mapAttrs'
# mapAttrsToList
# mkIf
# nameValuePair
# removeSuffix
;
cfg = config.custom.keybase; cfg = config.custom.keybase;
username = config.home.username; username = config.home.username;
secretstore = config._secretstore; secretstore = config._secretstore;
# 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}";
}
else nameValuePair "" null) (readDir dir);
filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs);
in { in {
# imports = [ # imports = [
@@ -28,7 +70,7 @@ in {
systemd.user.services.kbfs.Unit.After = [ "sops-nix.service" ]; systemd.user.services.kbfs.Unit.After = [ "sops-nix.service" ];
sops = { sops = {
secrets = 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/";
}; };
}; };
} }

View File

@@ -19,10 +19,10 @@ let
inherit (lib) makeExtensible attrValues foldr; inherit (lib) makeExtensible attrValues foldr;
inherit (modules) mapModules; inherit (modules) mapModules;
# modules = import ./modules.nix { modules = import ./modules.nix {
# inherit lib; inherit lib;
# self.attrs = import ./attrs.nix { inherit lib; self = {}; }; self.attrs = import ./attrs.nix { inherit lib; self = {}; };
# }; };
mylib = makeExtensible (self: mylib = makeExtensible (self:
with self; mapModules ./. with self; mapModules ./.

View File

@@ -1,123 +1,123 @@
# {lib, ...}: let {lib, ...}: let
# inherit inherit
# (builtins) (builtins)
# attrNames attrNames
# attrValues attrValues
# foldl' foldl'
# isPath isPath
# pathExists pathExists
# readDir readDir
# toString toString
# ; ;
# inherit inherit
# (lib) (lib)
# flatten flatten
# filterAttrs filterAttrs
# forEach forEach
# getAttrFromPath getAttrFromPath
# hasPrefix hasPrefix
# hasSuffix hasSuffix
# id id
# mapAttrs' mapAttrs'
# mapAttrsToList mapAttrsToList
# mkIf mkIf
# nameValuePair nameValuePair
# removeSuffix removeSuffix
# ; ;
# in rec { in rec {
# ## Mapping Functions ## ## Mapping Functions ##
# array = list: func: forEach list (name: getAttrFromPath [name] func); array = list: func: forEach list (name: getAttrFromPath [name] func);
# filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs); filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs);
# list = func: foldl' (x: y: x + y + " ") "" (attrNames func); list = func: foldl' (x: y: x + y + " ") "" (attrNames func);
# ## Files Map ## Files Map
# # Top Level # Top Level
# files = dir: func: extension: files = dir: func: extension:
# filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: let filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: let
# path = "${toString dir}/${name}"; path = "${toString dir}/${name}";
# in in
# if if
# (type == "directory" || type == "symlink") (type == "directory" || type == "symlink")
# && ( && (
# if (extension == ".nix") if (extension == ".nix")
# then pathExists "${path}/default.nix" then pathExists "${path}/default.nix"
# else true else true
# ) )
# then nameValuePair name (func path) then nameValuePair name (func path)
# else if else if
# type type
# == "regular" == "regular"
# && ( && (
# if (extension == ".nix") if (extension == ".nix")
# then name != "default.nix" then name != "default.nix"
# else true else true
# ) )
# && hasSuffix extension name && hasSuffix extension name
# then nameValuePair (removeSuffix extension name) (func path) then nameValuePair (removeSuffix extension name) (func path)
# else nameValuePair "" null) (readDir dir); else nameValuePair "" null) (readDir dir);
# # Recursive # Recursive
# files' = dir: func: extension: files' = dir: func: extension:
# filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: let filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: let
# path = "${toString dir}/${name}"; path = "${toString dir}/${name}";
# in in
# if (type == "directory" || type == "symlink") if (type == "directory" || type == "symlink")
# then nameValuePair name (files' path func) then nameValuePair name (files' path func)
# else if else if
# type type
# == "regular" == "regular"
# && ( && (
# if (extension == ".nix") if (extension == ".nix")
# then name != "default.nix" then name != "default.nix"
# else true else true
# ) )
# && hasSuffix extension name && hasSuffix extension name
# then nameValuePair (removeSuffix extension name) (func path) then nameValuePair (removeSuffix extension name) (func path)
# else nameValuePair "" null) (readDir dir); else nameValuePair "" null) (readDir dir);
# # Package Patches # Package Patches
# patches = patch: patches = patch:
# if isPath patch if isPath patch
# then then
# flatten (mapAttrsToList (name: type: flatten (mapAttrsToList (name: type:
# if if
# type type
# == "regular" == "regular"
# && (hasSuffix ".diff" name || hasSuffix ".patch" name) && (hasSuffix ".diff" name || hasSuffix ".patch" name)
# then patch + "/${name}" then patch + "/${name}"
# else null) (readDir patch)) else null) (readDir patch))
# else patch; else patch;
# # Module Imports # Module Imports
# module = dir: attrValues (modules dir id); module = dir: attrValues (modules dir id);
# module' = dir: attrNames (modules dir id); module' = dir: attrNames (modules dir id);
# modules = dir: func: files dir func ".nix"; modules = dir: func: files dir func ".nix";
# modules' = dir: func: files' dir func ".nix"; modules' = dir: func: files' dir func ".nix";
# # 'sops' Encrypted Secrets # 'sops' Encrypted Secrets
# secrets = dir: neededForUsers: secrets = dir: neededForUsers:
# filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: filter (name: type: type != null && !(hasPrefix "_" name)) (name: type:
# if type == "regular" && hasSuffix ".secret" name if type == "regular" && hasSuffix ".secret" name
# then then
# nameValuePair name { nameValuePair name {
# sopsFile = dir + "/${name}"; sopsFile = dir + "/${name}";
# format = "binary"; format = "binary";
# inherit neededForUsers; inherit neededForUsers;
# } }
# else nameValuePair "" null) (readDir dir); else nameValuePair "" null) (readDir dir);
# # 'sops' Encrypted Secrets # 'sops' Encrypted Secrets
# hm_secrets = dir: out_dir: hm_secrets = dir: out_dir:
# filter (name: type: type != null && !(hasPrefix "_" name)) (name: type: filter (name: type: type != null && !(hasPrefix "_" name)) (name: type:
# if type == "regular" && hasSuffix ".age" name if type == "regular" && hasSuffix ".age" name
# then then
# nameValuePair name { nameValuePair name {
# sopsFile = dir + "/${name}"; sopsFile = dir + "/${name}";
# format = "binary"; format = "binary";
# path = out_dir + "/${name}"; path = out_dir + "/${name}";
# } }
# else nameValuePair "" null) (readDir dir); else nameValuePair "" null) (readDir dir);
# } }