From c1a05b7e777dfc75da8c98a7a96628a0a98d7810 Mon Sep 17 00:00:00 2001 From: Milo Moisson Date: Thu, 4 Jan 2024 19:28:12 +0100 Subject: [PATCH] fix,refactor: see details - fix unused home manager configuration - place foreign packages in flake output - cleanup swaylock osConfig shenenigans - force overwrite mimeapps.list on HM switches --- flake.lock | 224 +++++++++++++++++++++++++++- flake.nix | 51 +++---- home-manager/modules/vm/default.nix | 12 +- home-manager/profiles/desktop.nix | 6 +- overlays/default.nix | 12 +- pkgs/default.nix | 8 +- 6 files changed, 268 insertions(+), 45 deletions(-) diff --git a/flake.lock b/flake.lock index e4c6c5e..681ba85 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "advisory-db": { + "flake": false, + "locked": { + "lastModified": 1701193254, + "narHash": "sha256-Hr7efA3GjwqBkGYKmd3XmGckdPQikbcCmOrq7fmTp3A=", + "owner": "rustsec", + "repo": "advisory-db", + "rev": "43af5fef0591531a72ebb86c5f1c623ee95c62fe", + "type": "github" + }, + "original": { + "owner": "rustsec", + "repo": "advisory-db", + "type": "github" + } + }, "agenix": { "inputs": { "darwin": "darwin", @@ -40,6 +56,27 @@ "type": "github" } }, + "crane": { + "inputs": { + "nixpkgs": [ + "radicle", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1701622587, + "narHash": "sha256-o3XhxCCyrUHZ0tlta2W7/MuXzy+n0+BUt3rKFK3DIK4=", + "owner": "ipetkov", + "repo": "crane", + "rev": "c09d2cbe84cc2adfe1943cb2a0b55a71c835ca9a", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -82,6 +119,110 @@ "type": "github" } }, + "fenix": { + "inputs": { + "nixpkgs": [ + "radicle", + "nixpkgs" + ], + "rust-analyzer-src": [ + "radicle" + ] + }, + "locked": { + "lastModified": 1701930186, + "narHash": "sha256-t9uIiU1fE7VXi3t460iOuAUW8Ece9mowRKva1aw48zI=", + "owner": "nix-community", + "repo": "fenix", + "rev": "aeb764a8e4c16da3f36b200a302552d8e457b9f4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "git-leave": { + "inputs": { + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1703088357, + "narHash": "sha256-/Fi7bXy5xRAhnvHIW3IjW+WLF27BpWylb37fn/+vepA=", + "owner": "mrnossiom", + "repo": "git-leave", + "rev": "e24341bb5d9f0393f8ce95076a91561e266ca475", + "type": "github" + }, + "original": { + "owner": "mrnossiom", + "repo": "git-leave", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-leave", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1694102001, + "narHash": "sha256-vky6VPK1n1od6vXbqzOXnekrQpTL4hbPAwUhT5J9c9E=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "9e21c80adf67ebcb077d75bd5e7d724d21eeafd6", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -204,16 +345,97 @@ "type": "github" } }, + "radicle": { + "inputs": { + "advisory-db": "advisory-db", + "crane": "crane", + "fenix": "fenix", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1704374633, + "narHash": "sha256-MC06q+I2sp8SnDijlfwj3KpvAMSLw/BFfUgmHzDB8L4=", + "ref": "refs/heads/master", + "rev": "2d710936087a0a41fc5f31bf2ab2c3dbe0a6e77f", + "revCount": 1585, + "type": "git", + "url": "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5" + }, + "original": { + "type": "git", + "url": "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5" + } + }, "root": { "inputs": { "agenix": "agenix", "disko": "disko", + "git-leave": "git-leave", "home-manager": "home-manager", "nix-colors": "nix-colors", "nix-index-database": "nix-index-database", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", - "nixpkgs-unstable": "nixpkgs-unstable" + "nixpkgs-unstable": "nixpkgs-unstable", + "radicle": "radicle" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "git-leave", + "flake-utils" + ], + "nixpkgs": [ + "git-leave", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1702520151, + "narHash": "sha256-jxJWosN7hgcW+dFT8V3EBDCYUOjv5tpjEBRmlakS7tU=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "d6a1d8f80dbcda4c13993b859a3574c3dde61072", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index c5da7f4..59750e3 100644 --- a/flake.nix +++ b/flake.nix @@ -6,37 +6,34 @@ nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; # Also see the 'unstable-packages' overlay at 'overlays/default.nix'. - home-manager = { - url = "github:nix-community/home-manager/release-23.11"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + home-manager.url = "github:nix-community/home-manager/release-23.11"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; - agenix = { - url = "github:ryantm/agenix"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.home-manager.follows = "home-manager"; - }; + agenix.url = "github:ryantm/agenix"; + agenix.inputs.nixpkgs.follows = "nixpkgs"; + agenix.inputs.home-manager.follows = "home-manager"; - nix-index-database = { - url = "github:Mic92/nix-index-database"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + nix-index-database.url = "github:Mic92/nix-index-database"; + nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; - disko = { - url = "github:nix-community/disko"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; nix-colors.url = "github:misterio77/nix-colors"; nixos-hardware.url = "github:nixos/nixos-hardware"; + + git-leave.url = "github:mrnossiom/git-leave"; + git-leave.inputs.nixpkgs.follows = "nixpkgs"; + + radicle.url = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5"; + radicle.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, home-manager, nixos-hardware, ... }: + outputs = { self, nixpkgs, nixos-hardware, ... }: let inherit (self) inputs outputs; inherit (nixpkgs.lib) nixosSystem genAttrs; - inherit (home-manager) homeManagerConfiguration; forAllSystems = genAttrs [ "aarch64-linux" "i686-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ]; flake-lib = import ./lib/flake (nixpkgs // { inherit self; }); @@ -45,7 +42,7 @@ inherit system; config.allowUnfreePredicate = import ./lib/unfree.nix; overlays = [ outputs.overlays.all ]; - }) // { inherit self; }); + })); in { formatter = forAllSystems (system: pkgs.${system}.nixpkgs-fmt); @@ -76,14 +73,14 @@ ]; }; - # In non-NixOS contexts, you can still home manager to manage dotfiles. - # Else, configuration is loaded by the HM NixOS module which create system generations and free rollbacks. + # I bundle my Home Manager config via the NixOS modules which create system generations and give free rollbacks. + # However, in non-NixOS contexts, you can still use Home Manager to manage dotfiles using this template. homeConfigurations = { - milomoisson = homeManagerConfiguration { - pkgs = nixpkgs.pkgs; - extraSpecialArgs = { inherit self; }; - modules = [ ./home-manager/profiles/desktop.nix ]; - }; + # "@" = homeManagerConfiguration { + # pkgs = pkgs.""; + # extraSpecialArgs = { inherit self; osConfig = null; }; + # modules = [ ./home-manager/profiles/desktop.nix ]; + # }; }; }; } diff --git a/home-manager/modules/vm/default.nix b/home-manager/modules/vm/default.nix index 117b108..e704a52 100644 --- a/home-manager/modules/vm/default.nix +++ b/home-manager/modules/vm/default.nix @@ -34,15 +34,11 @@ in ignore-empty-password = true; show-failed-attempts = true; - indicator-y-position = - if cfg != null - then ((cfg.height * 0.9) / cfg.scale) - else null; - indicator-x-position = - if cfg != null - then 100 - else null; image = toString ../../assets/BinaryCloud.png; + } + // optionalAttrs (cfg != null) { + indicator-y-position = ((cfg.height * 0.9) / cfg.scale); + indicator-x-position = 100; }; }; diff --git a/home-manager/profiles/desktop.nix b/home-manager/profiles/desktop.nix index dbbc6fe..33f3896 100644 --- a/home-manager/profiles/desktop.nix +++ b/home-manager/profiles/desktop.nix @@ -63,6 +63,8 @@ in HISTFILE = "${config.xdg.dataHome}/bash_history"; RUSTUP_HOME = "${config.xdg.dataHome}/rustup"; WAKATIME_HOME = "${config.xdg.configHome}/wakatime"; + W3M_DIR = "${config.xdg.configHome}/w3m"; + }; # Respect XDG spec @@ -90,7 +92,6 @@ in element-desktop xdg-utils - rustup # TODO: not sure to keep rustup in path spotify-tui # CLI tools @@ -127,6 +128,9 @@ in enableZshIntegration = true; }; + # Force override file which is not symlinked for whatever reason and causes errors on rebuilds + xdg.configFile."mimeapps.list".force = true; + programs.go = { enable = true; goPath = ".local/share/go"; diff --git a/overlays/default.nix b/overlays/default.nix index 5d0294d..046e379 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -8,21 +8,25 @@ let inherit (lib) composeManyExtensions; in rec { - all = composeManyExtensions [ local-lib additions patches unstable-packages ]; + # Bundles all overlays, order matters here + all = composeManyExtensions [ addFlakeAsSelf localLib additions patches unstablePackages ]; + + # Passing our flake as `self` makes it easy to access inputs and outputs + addFlakeAsSelf = final: prev: { inherit self; }; # Merge our local library to nixpkgs' - local-lib = final: prev: { + localLib = final: prev: { lib = { local = import ../lib final; } // prev.lib; }; # Bring our custom packages from the `pkgs` directory additions = final: prev: import ../pkgs prev; - # Custom derivation patches + # Custom derivation patches that temporarily fix a package patches = import ./patches.nix; # Makes the unstable nixpkgs set accessible through `pkgs.unstable` - unstable-packages = final: prev: { + unstablePackages = final: prev: { unstable = import nixpkgs-unstable { inherit (final) system config; }; }; } diff --git a/pkgs/default.nix b/pkgs/default.nix index 1d4e73c..720cbac 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,17 +1,17 @@ -{ system, ... }@pkgs: +{ self, system, ... }@pkgs: let - git-leave = builtins.getFlake "github:mrnossiom/git-leave/a4358d2769c0f93a5c8f7e7eb17e46f69e44d69e"; - rad = builtins.getFlake "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5?rev=150130e99beb04cd5d989932a617fcd160c7345a"; + inherit (self.inputs) git-leave radicle; in { thorium = pkgs.callPackage ./thorium.nix { }; greenlight = pkgs.callPackage ./greenlight.nix { }; + # Replace with custom crafted package findUnicode = pkgs.callPackage ./findUnicode.nix { }; # Import packages defined in foreign repositories # IDEA: move to a NUR repository inherit (git-leave.packages.${system}) git-leave; - inherit (rad.packages.${system}) radicle-cli radicle-remote-helper radicle-httpd radicle-node; + inherit (radicle.packages.${system}) radicle-cli radicle-remote-helper radicle-httpd radicle-node; }