From 71a947e285ee1ab179b867e8d89007b5e1d84f65 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Wed, 26 Mar 2025 20:40:46 +0800 Subject: [PATCH] refactor: flake.nix looks nicer --- flake.lock | 184 +++------------------------------ flake.nix | 85 ++++++--------- users/modules/programs/zsh.nix | 8 +- 3 files changed, 50 insertions(+), 227 deletions(-) diff --git a/flake.lock b/flake.lock index c479387..911423a 100644 --- a/flake.lock +++ b/flake.lock @@ -249,27 +249,6 @@ } }, "flake-parts_2": { - "inputs": { - "nixpkgs-lib": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1741352980, - "narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_3": { "inputs": { "nixpkgs-lib": "nixpkgs-lib_2" }, @@ -287,7 +266,7 @@ "type": "github" } }, - "flake-parts_4": { + "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "stylix", @@ -343,24 +322,6 @@ } }, "flake-utils_2": { - "inputs": { - "systems": "systems_4" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_3": { "inputs": { "systems": [ "stylix", @@ -381,9 +342,9 @@ "type": "github" } }, - "flake-utils_4": { + "flake-utils_3": { "inputs": { - "systems": "systems_8" + "systems": "systems_7" }, "locked": { "lastModified": 1731533236, @@ -1012,34 +973,6 @@ "type": "github" } }, - "ixx": { - "inputs": { - "flake-utils": [ - "nixvim", - "nuschtosSearch", - "flake-utils" - ], - "nixpkgs": [ - "nixvim", - "nuschtosSearch", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1729958008, - "narHash": "sha256-EiOq8jF4Z/zQe0QYVc3+qSKxRK//CFHMB84aYrYGwEs=", - "owner": "NuschtOS", - "repo": "ixx", - "rev": "9fd01aad037f345350eab2cd45e1946cc66da4eb", - "type": "github" - }, - "original": { - "owner": "NuschtOS", - "ref": "v0.0.6", - "repo": "ixx", - "type": "github" - } - }, "mnw": { "locked": { "lastModified": 1742255973, @@ -1181,22 +1114,6 @@ } }, "nixpkgs_10": { - "locked": { - "lastModified": 1742707865, - "narHash": "sha256-RVQQZy38O3Zb8yoRJhuFgWo/iDIDj0hEdRTVfhOtzRk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "dd613136ee91f67e5dba3f3f41ac99ae89c5406b", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_11": { "locked": { "lastModified": 1737003892, "narHash": "sha256-RCzJE9wKByLCXmRBp+z8LK9EgdW+K+W/DXnJS4S/NVo=", @@ -1340,28 +1257,6 @@ "type": "github" } }, - "nixvim": { - "inputs": { - "flake-parts": "flake-parts_2", - "nixpkgs": [ - "nixpkgs" - ], - "nuschtosSearch": "nuschtosSearch" - }, - "locked": { - "lastModified": 1742559284, - "narHash": "sha256-PSSjCCqpJPkCagkkdLODBVVonGxgwU5dN2CYlFPNVNw=", - "owner": "nix-community", - "repo": "nixvim", - "rev": "c980271267ef146a6c30394c611a97e077471cf2", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixvim", - "type": "github" - } - }, "nmd": { "flake": false, "locked": { @@ -1380,7 +1275,7 @@ }, "nur": { "inputs": { - "flake-parts": "flake-parts_4", + "flake-parts": "flake-parts_3", "nixpkgs": [ "stylix", "nixpkgs" @@ -1401,38 +1296,15 @@ "type": "github" } }, - "nuschtosSearch": { - "inputs": { - "flake-utils": "flake-utils", - "ixx": "ixx", - "nixpkgs": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1741886583, - "narHash": "sha256-sScfYKtxp3CYv5fJcHQDvQjqBL+tPNQqS9yf9Putd+s=", - "owner": "NuschtOS", - "repo": "search", - "rev": "2974bc5fa3441a319fba943f3ca41f7dcd1a1467", - "type": "github" - }, - "original": { - "owner": "NuschtOS", - "repo": "search", - "type": "github" - } - }, "nvf": { "inputs": { - "flake-parts": "flake-parts_3", - "flake-utils": "flake-utils_2", + "flake-parts": "flake-parts_2", + "flake-utils": "flake-utils", "mnw": "mnw", "nil": "nil", "nixpkgs": "nixpkgs_6", "nmd": "nmd", - "systems": "systems_5" + "systems": "systems_4" }, "locked": { "lastModified": 1742471089, @@ -1487,12 +1359,10 @@ "nixd": "nixd", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_5", - "nixvim": "nixvim", "nvf": "nvf", "sops-nix": "sops-nix", "spicetify-nix": "spicetify-nix", "stylix": "stylix", - "wii-cursor": "wii-cursor", "yazi": "yazi" } }, @@ -1560,7 +1430,7 @@ "spicetify-nix": { "inputs": { "nixpkgs": "nixpkgs_8", - "systems": "systems_6" + "systems": "systems_5" }, "locked": { "lastModified": 1742512598, @@ -1584,13 +1454,13 @@ "base16-vim": "base16-vim", "firefox-gnome-theme": "firefox-gnome-theme", "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_2", "git-hooks": "git-hooks", "gnome-shell": "gnome-shell", "home-manager": "home-manager_2", "nixpkgs": "nixpkgs_9", "nur": "nur", - "systems": "systems_7", + "systems": "systems_6", "tinted-foot": "tinted-foot", "tinted-kitty": "tinted-kitty", "tinted-schemes": "tinted-schemes", @@ -1716,21 +1586,6 @@ "type": "github" } }, - "systems_8": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "tinted-foot": { "flake": false, "locked": { @@ -1856,21 +1711,6 @@ "type": "github" } }, - "wii-cursor": { - "inputs": { - "nixpkgs": "nixpkgs_10" - }, - "locked": { - "lastModified": 1742819018, - "narHash": "sha256-B2HXOJxQgQVPiXkPCONP6d/SPaYYCz17iGABzPAfCIs=", - "path": "/home/rafiq/repos/dotfiles/media/wii-cursors-xcursor", - "type": "path" - }, - "original": { - "path": "/home/rafiq/repos/dotfiles/media/wii-cursors-xcursor", - "type": "path" - } - }, "xdph": { "inputs": { "hyprland-protocols": [ @@ -1914,8 +1754,8 @@ }, "yazi": { "inputs": { - "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_11", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_10", "rust-overlay": "rust-overlay_2" }, "locked": { diff --git a/flake.nix b/flake.nix index 11ab95a..153b273 100644 --- a/flake.nix +++ b/flake.nix @@ -1,73 +1,56 @@ { - description = "flake forward setup with two hosts on different architectures"; - outputs = { self, - nixpkgs, - home-manager, ... }@inputs: let - forEachSupportedSystem = - f: - nixpkgs.lib.genAttrs - [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ] - ( - system: - f { - pkgs = import nixpkgs { inherit system; }; - } - ); - args = { inherit self inputs; }; - mkSystem = - hostname: - nixpkgs.lib.nixosSystem { - specialArgs = args; - modules = [ - ./systems/${hostname}.nix - - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - extraSpecialArgs = args; - users.rafiq.imports = [ - ./users/rafiq.nix - ]; - }; - } - ]; - }; - mkListItem = hostname: { + mkSystem = type: hostname: { name = "${hostname}"; - value = mkSystem "${hostname}"; + value = + let + args = { inherit self inputs type; }; + in + inputs.nixpkgs.lib.nixosSystem { + specialArgs = args; + modules = [ + ./systems/${hostname}.nix + + inputs.home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = args; + users.rafiq.imports = [ + ./users/rafiq.nix + ]; + }; + } + ]; + }; }; in { # System Configurations nixosConfigurations = builtins.listToAttrs [ - (mkListItem "nemesis") - (mkListItem "mellinoe") + (mkSystem "desktop" "nemesis") + (mkSystem "desktop" "mellinoe") ]; }; inputs = { - hyprland-plugins.inputs.hyprland.follows = "hyprland"; - hyprland-plugins.url = "github:hyprwm/hyprland-plugins"; - wii-cursor.path = "/home/rafiq/repos/dotfiles/media/wii-cursors-xcursor"; - wii-cursor.type = "path"; + ags.inputs.nixpkgs.follows = "nixpkgs"; + ags.url = "github:aylur/ags"; + astal.inputs.nixpkgs.follows = "nixpkgs"; + astal.url = "github:aylur/astal"; disko.inputs.nixpkgs.follows = "nixpkgs"; disko.url = "github:nix-community/disko/latest"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; home-manager.url = "github:nix-community/home-manager"; hyprcloser.url = "github:rrvsh/hyprcloser"; + hyprland-plugins.inputs.hyprland.follows = "hyprland"; + hyprland-plugins.url = "github:hyprwm/hyprland-plugins"; hyprland.url = "github:hyprwm/Hyprland"; hyprlock.url = "github:hyprwm/hyprlock"; hyprshaders.flake = false; @@ -78,16 +61,10 @@ nixd.url = "github:nix-community/nixd"; nixos-hardware.url = "github:nixos/nixos-hardware"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - nixvim.inputs.nixpkgs.follows = "nixpkgs"; - nixvim.url = "github:nix-community/nixvim"; nvf.url = "github:notashelf/nvf"; sops-nix.url = "github:Mic92/sops-nix"; spicetify-nix.url = "github:Gerg-L/spicetify-nix"; stylix.url = "github:danth/stylix"; yazi.url = "github:sxyazi/yazi"; - astal.url = "github:aylur/astal"; - astal.inputs.nixpkgs.follows = "nixpkgs"; - ags.url = "github:aylur/ags"; - ags.inputs.nixpkgs.follows = "nixpkgs"; }; } diff --git a/users/modules/programs/zsh.nix b/users/modules/programs/zsh.nix index e01926a..0d32c53 100644 --- a/users/modules/programs/zsh.nix +++ b/users/modules/programs/zsh.nix @@ -1,4 +1,9 @@ -{ pkgs, osConfig, ... }: +{ + pkgs, + osConfig, + type, + ... +}: { programs.zsh = { enable = true; @@ -14,6 +19,7 @@ bindkey '^H' backward-kill-word # Set Cargo Registry Token export CARGO_REGISTRY_TOKEN="$(cat ${osConfig.sops.secrets.cargo_api_key.path})" + export SYSTEM_TYPE="${type}" ''; # TODO: Look into whether we need to add the history attribute profileExtra = # bash