From a45de9e2e216cf73e976192814cdbdbb9164be30 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 26 May 2026 13:27:07 -0400 Subject: make lib extendable with our additions --- flake.nix | 12 ++++--- home/apps/caelestia/scheme.nix | 5 ++- home/gpg.nix | 2 +- hosts/kaworu/default.nix | 4 +-- hosts/shinji/default.nix | 8 +++-- lib/colors.nix | 2 +- lib/default.nix | 77 +++--------------------------------------- lib/files.nix | 9 ++--- lib/home.nix | 66 ++++++++++++++++++++++++++++++++++++ lib/monitors.nix | 34 +++++++++---------- system/amdgpu.nix | 2 +- system/default.nix | 4 +-- system/sshd.nix | 3 +- 13 files changed, 113 insertions(+), 115 deletions(-) create mode 100644 lib/home.nix diff --git a/flake.nix b/flake.nix index 1f51864..9a6dc80 100644 --- a/flake.nix +++ b/flake.nix @@ -55,10 +55,12 @@ } ) systems); - mkSystem = hostDir: system: - nixpkgs.lib.nixosSystem { + mkSystem = hostDir: system: let + lib = nixpkgs.lib.extend (_: _: self.lib); + in + lib.nixosSystem { inherit system; - specialArgs = {inherit inputs system hostDir;}; + specialArgs = {inherit inputs system hostDir lib;}; modules = [ ./system ./options.nix @@ -67,10 +69,11 @@ }; mkHome = hostDir: system: let hostModule = mkSystem hostDir system; + lib = nixpkgs.lib.extend (_: _: self.lib); in home-manager.lib.homeManagerConfiguration { inherit (hostModule) pkgs; - extraSpecialArgs = {inherit inputs system hostDir;}; + extraSpecialArgs = {inherit inputs system hostDir lib;}; modules = [ ./home ./options.nix @@ -97,7 +100,6 @@ }; lib = import ./lib { - inherit inputs; inherit (nixpkgs) lib; }; diff --git a/home/apps/caelestia/scheme.nix b/home/apps/caelestia/scheme.nix index 06991d9..ac4042c 100644 --- a/home/apps/caelestia/scheme.nix +++ b/home/apps/caelestia/scheme.nix @@ -1,11 +1,10 @@ { lib, config, - inputs, ... -}: -with inputs.self.lib; let +}: let inherit (lib) mkIf; + inherit (lib.colors) mixColor; cfg = config.apps.caelestia; theme = config.theme.colors; in { diff --git a/home/gpg.nix b/home/gpg.nix index ae2614c..bbfbbeb 100644 --- a/home/gpg.nix +++ b/home/gpg.nix @@ -14,7 +14,7 @@ # source = path; # trust = 5; # }) - # inputs.self.lib.gpgKeys; + # lib.files.gpgKeys; }; # global gpg agent diff --git a/hosts/kaworu/default.nix b/hosts/kaworu/default.nix index f20f400..48461d3 100644 --- a/hosts/kaworu/default.nix +++ b/hosts/kaworu/default.nix @@ -1,13 +1,13 @@ # Kaworu # System configuration for my desktop -{ inputs, ... }: { +{lib, ...}: { imports = [ ./hardware.nix ]; # options hostName = "kaworu"; - monitors = with inputs.self.lib.monitors; [ + monitors = with lib.monitors; [ asus acer ]; diff --git a/hosts/shinji/default.nix b/hosts/shinji/default.nix index 28c9658..916fa52 100644 --- a/hosts/shinji/default.nix +++ b/hosts/shinji/default.nix @@ -1,13 +1,17 @@ # Shinji # System configuration for my laptop -{pkgs, inputs, ...}: { +{ + pkgs, + lib, + ... +}: { imports = [ ./hardware.nix ]; # options hostName = "shinji"; - monitors = with inputs.self.lib.monitors; [ + monitors = with lib.monitors; [ { port = "eDP-1"; laptop = true; diff --git a/lib/colors.nix b/lib/colors.nix index a653f11..27f29bb 100644 --- a/lib/colors.nix +++ b/lib/colors.nix @@ -1,4 +1,4 @@ -{lib, ...}: let +{lib}: let colorToInt = hex: let table = { "0" = 0; diff --git a/lib/default.nix b/lib/default.nix index dcfb442..2842af4 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,75 +1,8 @@ -{lib, ...} @ inputs: let - callLibs = file: import file inputs; - files = callLibs ./files.nix; +{lib}: let + callLibs = file: import file {inherit lib;}; +in { colors = callLibs ./colors.nix; + files = callLibs ./files.nix; + home = callLibs ./home.nix; monitors = callLibs ./monitors.nix; -in { - inherit (files) getFiles certs sshKeys gpgKeys; - inherit (colors) colorToInt colorToHex darkenColor lightenColor mixColor; - inherit monitors; - - # set of options we want to copy from a system - # config to home manager - homeConfig = config: - { - inherit - (config) - # System Information - hostName - timeZone - stateVersion - # System Modules - battery - bluetooth - fingerprint - network - tpm - nvidia - minimal - # Primary User - user - fullName - email - homePath - dotfilesPath - # Monitors - monitors - # Theme - theme - # Programs - apps - browsers - desktops - gaming - development - virt - autoRun - # Packages - extraPackages - ; - # fix xdg - xdg.portal = { - inherit - (config.xdg.portal) - enable - xdgOpenUsePortal - extraPortals - config - ; - }; - # bring over nix options - nix = lib.mkForce { - inherit - (config.nix) - buildMachines - checkConfig - distributedBuilds - gc - package - registry - settings - ; - }; - } - // config.extraHome; } diff --git a/lib/files.nix b/lib/files.nix index 960d1d0..c75508c 100644 --- a/lib/files.nix +++ b/lib/files.nix @@ -1,8 +1,8 @@ -{lib, ...}: let +{lib}: let # gets list of files from a directory getFiles = folder: lib.attrsets.mapAttrsToList (name: _: "${folder}/${name}") (builtins.readDir folder); - +in { # gets custom set of root certs certs = getFiles ../files/certs; @@ -15,9 +15,4 @@ gpgKeys = builtins.filter (filePath: lib.strings.hasSuffix "asc" filePath) (getFiles ../files/keys); -in { - inherit getFiles; - inherit certs; - inherit sshKeys; - inherit gpgKeys; } diff --git a/lib/home.nix b/lib/home.nix new file mode 100644 index 0000000..4b4ec02 --- /dev/null +++ b/lib/home.nix @@ -0,0 +1,66 @@ +{lib}: { + # set of options we want to copy from a system + # config to home manager + mkConfig = config: + { + inherit + (config) + # System Information + hostName + timeZone + stateVersion + # System Modules + battery + bluetooth + fingerprint + network + tpm + nvidia + minimal + # Primary User + user + fullName + email + homePath + dotfilesPath + # Monitors + monitors + # Theme + theme + # Programs + apps + browsers + desktops + gaming + development + virt + autoRun + # Packages + extraPackages + ; + # fix xdg + xdg.portal = { + inherit + (config.xdg.portal) + enable + xdgOpenUsePortal + extraPortals + config + ; + }; + # bring over nix options + nix = lib.mkForce { + inherit + (config.nix) + buildMachines + checkConfig + distributedBuilds + gc + package + registry + settings + ; + }; + } + // config.extraHome; +} diff --git a/lib/monitors.nix b/lib/monitors.nix index 603b491..4cb2977 100644 --- a/lib/monitors.nix +++ b/lib/monitors.nix @@ -1,21 +1,21 @@ -_: let - asus = { - desc = "ASUSTek COMPUTER INC ASUS VA24E LALMTF215939"; - position = { - enabled = true; - x = 2048; - y = 240; - }; +_: { + # 1080p small ASUS monitor + asus = { + desc = "ASUSTek COMPUTER INC ASUS VA24E LALMTF215939"; + position = { + enabled = true; + x = 2048; + y = 240; }; + }; - acer = { - desc = "Acer Technologies EB321HQU 0x00000698"; - position = { - enabled = true; - x = 3968; - y = 0; - }; + # 1440p 32in acer + acer = { + desc = "Acer Technologies EB321HQU 0x00000698"; + position = { + enabled = true; + x = 3968; + y = 0; }; -in { - inherit asus acer; + }; } diff --git a/system/amdgpu.nix b/system/amdgpu.nix index de58a62..df9a52c 100644 --- a/system/amdgpu.nix +++ b/system/amdgpu.nix @@ -15,7 +15,7 @@ in { }; # AMD Anti-Lag - environment.systemPackages = [ pkgs.low-latency-layer ]; + environment.systemPackages = [pkgs.low-latency-layer]; environment.etc."vulkan/implicit_layer.d/low_latency_layer.json".source = "${pkgs.low-latency-layer}/share/vulkan/implicit_layer.d/low_latency_layer.json"; # Configuration diff --git a/system/default.nix b/system/default.nix index fd2e1cc..17462d8 100644 --- a/system/default.nix +++ b/system/default.nix @@ -92,7 +92,7 @@ in { imports = [ ../home ../options.nix - (inputs.self.lib.homeConfig config) + (lib.home.mkConfig config) ]; }; @@ -180,7 +180,7 @@ in { }; # certs - security.pki.certificateFiles = inputs.self.lib.certs; + security.pki.certificateFiles = lib.files.certs; # sudo security.sudo.enable = false; diff --git a/system/sshd.nix b/system/sshd.nix index e60da43..088b6e1 100644 --- a/system/sshd.nix +++ b/system/sshd.nix @@ -1,7 +1,6 @@ { lib, config, - inputs, ... }: let inherit (lib) mkIf; @@ -35,7 +34,7 @@ in { # add authorized keys users.users.${config.user} = { - openssh.authorizedKeys.keyFiles = inputs.self.lib.sshKeys; + openssh.authorizedKeys.keyFiles = lib.files.sshKeys; }; }; } -- cgit v1.3.1-freya