From 26c9cfbaed8de65056dc66c59641ebe404f1a2a0 Mon Sep 17 00:00:00 2001 From: Ahmad Ansori Palembani Date: Sat, 2 Nov 2024 10:06:35 +0700 Subject: [PATCH] refactor(nix): Mix stable and unstable packages Also replace inkscape with brew cask inkscape on macOS --- .config/nix/flake.lock | 43 ++++++++++++++------ .config/nix/flake.nix | 27 ++++++------ .config/nix/lib/mkCommon.nix | 4 +- .config/nix/lib/mkSystem.nix | 16 ++++++-- .config/nix/overlays/python.nix | 20 +++++---- .config/nix/systems/darwin/configuration.nix | 3 +- .config/nix/systems/darwin/default.nix | 40 +++++++++++------- .config/nix/systems/nix/default.nix | 14 +++++-- .config/nix/systems/nix/potato/default.nix | 2 +- .config/nix/users/default.nix | 30 ++++++++++---- .config/nix/users/ziro/darwin.nix | 2 +- .config/nix/users/ziro/default.nix | 2 +- .config/nix/users/ziro/linux.nix | 2 +- 13 files changed, 133 insertions(+), 72 deletions(-) diff --git a/.config/nix/flake.lock b/.config/nix/flake.lock index 0eab190..2cb756e 100644 --- a/.config/nix/flake.lock +++ b/.config/nix/flake.lock @@ -26,7 +26,7 @@ "nix-darwin" ], "nixpkgs": [ - "nixpkgs" + "nixpkgs-stable" ] }, "locked": { @@ -83,7 +83,7 @@ "firefox-darwin": { "inputs": { "nixpkgs": [ - "nixpkgs" + "nixpkgs-stable" ] }, "locked": { @@ -177,7 +177,7 @@ "home-manager": { "inputs": { "nixpkgs": [ - "nixpkgs" + "nixpkgs-unstable" ] }, "locked": { @@ -198,7 +198,7 @@ "nix-darwin": { "inputs": { "nixpkgs": [ - "nixpkgs" + "nixpkgs-stable" ] }, "locked": { @@ -237,23 +237,23 @@ "type": "github" } }, - "nixpkgs": { + "nixpkgs-stable": { "locked": { - "lastModified": 1730272153, - "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", + "lastModified": 1730503127, + "narHash": "sha256-RRidUbyqCiFgFfJ5VbvuEVl2j2+p89QPmSyplID7VQM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", + "rev": "acc2a23c96439823bc751e726b62a44d80cf76ee", "type": "github" }, "original": { "owner": "NixOS", + "ref": "release-24.05", "repo": "nixpkgs", - "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", "type": "github" } }, - "nixpkgs-stable": { + "nixpkgs-stable_2": { "locked": { "lastModified": 1720386169, "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", @@ -269,6 +269,22 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1730272153, + "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", + "type": "github" + } + }, "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat", @@ -277,7 +293,7 @@ "system-manager", "nixpkgs" ], - "nixpkgs-stable": "nixpkgs-stable" + "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { "lastModified": 1728092656, @@ -300,7 +316,8 @@ "firefox-darwin": "firefox-darwin", "home-manager": "home-manager", "nix-darwin": "nix-darwin", - "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable", + "nixpkgs-unstable": "nixpkgs-unstable", "system-manager": "system-manager" } }, @@ -332,7 +349,7 @@ "flake-utils": "flake-utils_2", "nix-vm-test": "nix-vm-test", "nixpkgs": [ - "nixpkgs" + "nixpkgs-stable" ], "pre-commit-hooks": "pre-commit-hooks", "rust-overlay": "rust-overlay", diff --git a/.config/nix/flake.nix b/.config/nix/flake.nix index 2d6d0fb..6bae42b 100644 --- a/.config/nix/flake.nix +++ b/.config/nix/flake.nix @@ -1,7 +1,7 @@ { description = "null2264's Nix Setup"; - outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager, system-manager, ... }: + outputs = inputs@{ self, nix-darwin, nixpkgs-stable, nixpkgs-unstable, home-manager, system-manager, ... }: let vars = { floorp = { @@ -13,42 +13,43 @@ { darwinConfigurations = ( import ./systems/darwin { - inherit (nixpkgs) lib; - inherit inputs nixpkgs nix-darwin home-manager vars; + inherit (nixpkgs-unstable) lib; + inherit inputs nixpkgs-stable nixpkgs-unstable nix-darwin home-manager vars; } ); systemConfigs = ( # sudo is required, sadly import ./systems/nix { - inherit (nixpkgs) lib; - inherit inputs nixpkgs system-manager home-manager vars; + inherit (nixpkgs-unstable) lib; + inherit inputs nixpkgs-stable nixpkgs-unstable system-manager home-manager vars; } ); homeConfigurations = ( import ./users { - inherit (nixpkgs) lib; - inherit inputs nixpkgs home-manager vars; + inherit (nixpkgs-unstable) lib; + inherit inputs nixpkgs-stable nixpkgs-unstable home-manager vars; } ); }; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53"; + nixpkgs-stable.url = "github:NixOS/nixpkgs/release-24.05"; + nixpkgs-unstable.url = "github:NixOS/nixpkgs/2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53"; nix-darwin = { url = "github:LnL7/nix-darwin/470f87c1827b51169ed4f91cdbdfd48417bfff3d"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "nixpkgs-stable"; }; firefox-darwin = { url = "github:bandithedoge/nixpkgs-firefox-darwin"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "nixpkgs-stable"; }; brew-nix = { url = "github:BatteredBunny/brew-nix/d3d3a2666e5330e83b6a64b1eb3e1e9380f6da9b"; inputs.nix-darwin.follows = "nix-darwin"; inputs.brew-api.follows = "brew-api"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "nixpkgs-stable"; }; brew-api = { url = "github:BatteredBunny/brew-api"; @@ -57,12 +58,12 @@ home-manager = { url = "github:nix-community/home-manager/64c6325b28ebd708653dd41d88f306023f296184"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; # we need unstable (24.11) for programs.floorp. FIXME: switch to stable once 24.11 become stable }; system-manager = { url = "github:numtide/system-manager/c93e62f2e962b54fd961798731d25eaa5778dbe2"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "nixpkgs-stable"; }; }; } diff --git a/.config/nix/lib/mkCommon.nix b/.config/nix/lib/mkCommon.nix index 5e51c99..2821289 100644 --- a/.config/nix/lib/mkCommon.nix +++ b/.config/nix/lib/mkCommon.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, pkgs-unstable, ... }: let custom = { @@ -8,11 +8,13 @@ let py.dnspython ])); }; + custom.inkscape = if pkgs.stdenv.isDarwin then pkgs.brewCasks.inkscape else (pkgs.inkscape.override { python3 = custom.python; }); in { inherit custom; packages = [ pkgs.zsh pkgs.home-manager pkgs.zoxide + custom.inkscape ]; } diff --git a/.config/nix/lib/mkSystem.nix b/.config/nix/lib/mkSystem.nix index d051163..41a53c6 100644 --- a/.config/nix/lib/mkSystem.nix +++ b/.config/nix/lib/mkSystem.nix @@ -1,9 +1,17 @@ -system: nixpkgs: extraOverlays: +{ arch, stable, unstable, extraOverlays ? [] }: { - system = system; - pkgs = import nixpkgs { - inherit system; + system = arch; + pkgs = import stable { + system = arch; + overlays = + [ + (import ../overlays/python.nix) + ] ++ extraOverlays; + config.allowUnfree = true; + }; + pkgs-unstable = import unstable { + system = arch; overlays = [ (import ../overlays/python.nix) diff --git a/.config/nix/overlays/python.nix b/.config/nix/overlays/python.nix index a8b6ea9..922d03d 100644 --- a/.config/nix/overlays/python.nix +++ b/.config/nix/overlays/python.nix @@ -7,13 +7,15 @@ let dontCheck = true; }); in { - pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [(pyfinal: pyprev: { - dnspython = (disablePyChecks pyprev.dnspython).overridePythonAttrs (old: { - disabledTests = [ - "test_resolver" # Relying too much on internet connection, Indonesian internet couldn't cope with it - ] ++ old.disabledTests; - }); - pillow = disablePyChecks pyprev.pillow; # Inconsistent test result - cherrypy = disablePyChecks pyprev.cherrypy; # Inconsistent test result - })]; + pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ + (pyfinal: pyprev: { + dnspython = (disablePyChecks pyprev.dnspython).overridePythonAttrs (old: { + disabledTests = [ + "test_resolver" # Relying too much on internet connection, Indonesian internet couldn't cope with it + ] ++ old.disabledTests; + }); + pillow = disablePyChecks pyprev.pillow; # Inconsistent test result + cherrypy = disablePyChecks pyprev.cherrypy; # Inconsistent test result + }) + ]; } diff --git a/.config/nix/systems/darwin/configuration.nix b/.config/nix/systems/darwin/configuration.nix index fbb43d0..401db77 100644 --- a/.config/nix/systems/darwin/configuration.nix +++ b/.config/nix/systems/darwin/configuration.nix @@ -1,4 +1,4 @@ -{ pkgs, config, vars, common, inputs, ... }: +{ pkgs, pkgs-unstable, config, vars, common, inputs, ... }: { # I don't want to risk breaking my hackintosh setup in case Apple decided to @@ -17,7 +17,6 @@ pkgs.gnupg pkgs.htop-vim common.custom.python - (pkgs.inkscape.override { python3 = common.custom.python; }) #(pkgs.poetry.override { python3 = common.custom.python; }) pkgs.fastfetch pkgs.eza diff --git a/.config/nix/systems/darwin/default.nix b/.config/nix/systems/darwin/default.nix index fffbf9a..417f3db 100644 --- a/.config/nix/systems/darwin/default.nix +++ b/.config/nix/systems/darwin/default.nix @@ -1,4 +1,4 @@ -{ inputs, nixpkgs, nix-darwin, vars, ... }: +{ inputs, nixpkgs-stable, nixpkgs-unstable, nix-darwin, vars, ... }: let mkCommon = import ../../lib/mkCommon.nix; @@ -14,16 +14,21 @@ in "ThiccBook-Pro" = let inherit ( - mkSystem "x86_64-darwin" nixpkgs [ - inputs.firefox-darwin.overlay - inputs.brew-nix.overlays.default - ] - ) system pkgs; - common = (mkCommon pkgs); + mkSystem { + arch = "x86_64-darwin"; + stable = nixpkgs-stable; + unstable = nixpkgs-unstable; + extraOverlays = [ + inputs.firefox-darwin.overlay + inputs.brew-nix.overlays.default + ]; + } + ) system pkgs pkgs-unstable; + common = (mkCommon { inherit pkgs pkgs-unstable; }); in nix-darwin.lib.darwinSystem { inherit system; - specialArgs = { inherit inputs pkgs vars common; }; + specialArgs = { inherit inputs pkgs pkgs-unstable vars common; }; modules = [ ./configuration.nix ]; @@ -33,16 +38,21 @@ in MacBookProM1 = let inherit ( - mkSystem "aarch64-darwin" nixpkgs [ - inputs.firefox-darwin.overlay - inputs.brew-nix.overlays.default - ] - ) system pkgs; - common = (mkCommon pkgs); + mkSystem { + arch = "aarch64-darwin"; + stable = nixpkgs-stable; + unstable = nixpkgs-unstable; + extraOverlays = [ + inputs.firefox-darwin.overlay + inputs.brew-nix.overlays.default + ]; + } + ) system pkgs pkgs-unstable; + common = (mkCommon { inherit pkgs pkgs-unstable; }); in nix-darwin.lib.darwinSystem { inherit system; - specialArgs = { inherit inputs pkgs vars common; }; + specialArgs = { inherit inputs pkgs pkgs-unstable vars common; }; modules = [ ./configuration.nix ]; diff --git a/.config/nix/systems/nix/default.nix b/.config/nix/systems/nix/default.nix index 001588e..444919c 100644 --- a/.config/nix/systems/nix/default.nix +++ b/.config/nix/systems/nix/default.nix @@ -1,4 +1,4 @@ -{ inputs, nixpkgs, system-manager, vars, ... }: +{ inputs, nixpkgs-stable, nixpkgs-unstable, system-manager, vars, ... }: let mkCommon = import ../../lib/mkCommon.nix; @@ -7,11 +7,17 @@ in { "potato" = let - inherit (mkSystem "x86_64-linux" nixpkgs []) system pkgs; - common = (mkCommon pkgs); + inherit ( + mkSystem { + arch = "x86_64-linux"; + stable = nixpkgs-stable; + unstable = nixpkgs-unstable; + } + ) system pkgs pkgs-unstable; + common = (mkCommon { inherit pkgs pkgs-unstable; }); in system-manager.lib.makeSystemConfig { - extraSpecialArgs = { inherit inputs pkgs vars common; }; + extraSpecialArgs = { inherit inputs pkgs pkgs-unstable vars common; }; modules = [ ./potato ]; diff --git a/.config/nix/systems/nix/potato/default.nix b/.config/nix/systems/nix/potato/default.nix index e88eadf..9c08006 100644 --- a/.config/nix/systems/nix/potato/default.nix +++ b/.config/nix/systems/nix/potato/default.nix @@ -1,4 +1,4 @@ -{ pkgs, config, vars, common, ... }: +{ pkgs, pkgs-unstable, config, vars, common, ... }: { config = { diff --git a/.config/nix/users/default.nix b/.config/nix/users/default.nix index 1c0121e..e8439b6 100644 --- a/.config/nix/users/default.nix +++ b/.config/nix/users/default.nix @@ -1,4 +1,4 @@ -{ inputs, nixpkgs, home-manager, vars, ... }: +{ inputs, nixpkgs-stable, nixpkgs-unstable, home-manager, vars, ... }: let mkSystem = import ../lib/mkSystem.nix; @@ -18,13 +18,23 @@ in "ziro@ThiccBook-Pro" = let - inherit (mkSystem "x86_64-darwin" nixpkgs [inputs.firefox-darwin.overlay]) system pkgs; + inherit ( + mkSystem { + arch = "x86_64-darwin"; + stable = nixpkgs-stable; + unstable = nixpkgs-unstable; + extraOverlays = [ + inputs.firefox-darwin.overlay + inputs.brew-nix.overlays.default + ]; + } + ) system pkgs pkgs-unstable; vars.name = "ziro"; vars.floorp.verticalTabHoverWidthInEm = 28; in home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { inherit inputs pkgs home-manager vars; }; + pkgs = pkgs-unstable; # FIXME: switch to stable when 24.11 become stable + extraSpecialArgs = { inherit inputs pkgs pkgs-unstable home-manager vars; }; modules = [ ./ziro ./ziro/darwin.nix @@ -34,12 +44,18 @@ in "ziro@potato" = let - inherit (mkSystem "x86_64-linux" nixpkgs []) system pkgs; + inherit ( + mkSystem { + arch = "x86_64-linux"; + stable = nixpkgs-stable; + unstable = nixpkgs-unstable; + } + ) system pkgs pkgs-unstable; vars.name = "ziro"; in home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { inherit inputs pkgs home-manager vars; }; + pkgs = pkgs-unstable; # FIXME: switch to stable when 24.11 become stable + extraSpecialArgs = { inherit inputs pkgs pkgs-unstable home-manager vars; }; modules = [ ./ziro ./ziro/linux.nix diff --git a/.config/nix/users/ziro/darwin.nix b/.config/nix/users/ziro/darwin.nix index 951649d..97d0dee 100644 --- a/.config/nix/users/ziro/darwin.nix +++ b/.config/nix/users/ziro/darwin.nix @@ -1,4 +1,4 @@ -{ pkgs, config, vars, ... }: +{ pkgs, pkgs-unstable, config, vars, ... }: { home.homeDirectory = "/Users/ziro"; diff --git a/.config/nix/users/ziro/default.nix b/.config/nix/users/ziro/default.nix index 422e066..9b60a2c 100644 --- a/.config/nix/users/ziro/default.nix +++ b/.config/nix/users/ziro/default.nix @@ -1,4 +1,4 @@ -{ pkgs, config, vars, ... }: +{ pkgs, pkgs-unstable, config, vars, ... }: { home = { diff --git a/.config/nix/users/ziro/linux.nix b/.config/nix/users/ziro/linux.nix index 49d8c21..8bab357 100644 --- a/.config/nix/users/ziro/linux.nix +++ b/.config/nix/users/ziro/linux.nix @@ -1,4 +1,4 @@ -{ pkgs, config, vars, ... }: +{ pkgs, pkgs-unstable, config, vars, ... }: { home.homeDirectory = "/home/ziro";