From 8ac1645121900a52f914ccb7c8d87faea64da282 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Fri, 7 Nov 2025 16:45:29 +0100 Subject: [PATCH] dix --- flake.nix | 3 ++- justfile | 5 +++++ profiles/base/ccache/default.nix | 2 +- profiles/base/upgrade-diff.nix | 27 ++++++++++++++++++----- users/pbsds/home/profiles/git.nix | 7 +++++- users/pbsds/home/profiles/update-diff.nix | 25 ++++++++++++++++----- 6 files changed, 56 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index 6abd4cf..278491b 100644 --- a/flake.nix +++ b/flake.nix @@ -297,13 +297,13 @@ self.packages.${system}.nom-nixos-rebuild-ng self.packages.${system}.nom-home-manager pkgs.nix-output-monitor - # pkgs.cachix pkgs.age pkgs.sops pkgs.ssh-to-age pkgs.just pkgs.gum pkgs.mprocs + pkgs.dix # pkgs.nvd ]; in rec { envrc = mkShell { } envrc-pkgs; @@ -321,6 +321,7 @@ pkgs.just pkgs.gum # pkgs.lix # bruh, debian, why so old + pkgs.dix # pkgs.nvd ]; envrc-fhs = mkShell { inheritFrom = [ envrc ]; } [ system-manager ]; envrc-remotes-fhs = mkShell { inheritFrom = [ envrc-remotes ]; } [ system-manager ]; diff --git a/justfile b/justfile index 8b6e707..8c683f5 100644 --- a/justfile +++ b/justfile @@ -53,6 +53,11 @@ pull-dconf: -gum confirm "git checkout --path?" --default=no \ && git checkout --patch ./users/pbsds/home/profiles/desktop/gnome/ +# compares new closure against /run/current-system +@build-diff: build + # nvd diff /run/current-system ./result # python based, slow + dix /run/current-system ./result # rust based, fast, nixos-unstable only + # todo: support system-manager # todo: support home-manager? build hostname="" *_: diff --git a/profiles/base/ccache/default.nix b/profiles/base/ccache/default.nix index 6cd767f..4a13654 100644 --- a/profiles/base/ccache/default.nix +++ b/profiles/base/ccache/default.nix @@ -64,7 +64,7 @@ my $v = shift; return '--version' if $v eq '-V' || $v eq '--version'; return '-s' if $v eq '-s' || $v eq '--show-stats'; - return '--show-adv-stats' if $v eq '--show-adv-stats'; + return '--show-adv-stats' if $v eq '--show-adv-stats'; return '-z' if $v eq '-z' || $v eq '--zero-stats'; exec('${lib.getExe pkgs.sccache}', '-h'); } diff --git a/profiles/base/upgrade-diff.nix b/profiles/base/upgrade-diff.nix index 827b309..22cc0df 100644 --- a/profiles/base/upgrade-diff.nix +++ b/profiles/base/upgrade-diff.nix @@ -1,14 +1,31 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { + # dix: https://github.com/faukah/dix + # rust based + # module from https://github.com/getchoo/borealis/blob/a35749aa6280fbe4cbe72291bb9c4cc643780c76/modules/nixos/custom/activation-diff.nix + # nvd: https://discourse.nixos.org/t/nvd-simple-nix-nixos-version-diff-tool/12397 + # python based # module from https://github.com/luishfonseca/dotfiles/blob/ab7625ec406b48493eda701911ad1cd017ce5bc1/modules/upgrade-diff.nix + # gated on formatAttr which is set by nixos-generators - system.activationScripts.diff = lib.mkIf ((config.formatAttr or null) == null) { + system.activationScripts.show-nixos-closure-diff = lib.mkIf ((config.formatAttr or null) == null) { supportsDryActivation = true; - text = '' - ${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff /run/current-system "$systemConfig" - ''; + text = + if pkgs ? dix then + '' + ${pkgs.dix}/bin/dix /run/current-system "$systemConfig" + '' + else + '' + ${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff /run/current-system "$systemConfig" + ''; }; } diff --git a/users/pbsds/home/profiles/git.nix b/users/pbsds/home/profiles/git.nix index b51e93b..df4279a 100644 --- a/users/pbsds/home/profiles/git.nix +++ b/users/pbsds/home/profiles/git.nix @@ -43,11 +43,16 @@ features.syntax-theme = lib.mkIf config.programs.bat.enable config.programs.bat.config.theme; }; #programs.git.lfs.enable = true; - #programs.git.signing #programs.git.userName = "pbsds" programs.git.userName = "Peder Bergebakken Sundt"; programs.git.userEmail = "pbsds@hotmail.com"; + # # sign commits with ssh key + # programs.git.extraConfig.gpg.format = "ssh"; + # programs.git.signing.key = "${config.home.homeDirectory}/.ssh/my-key.pub"; + # programs.git.signing.signByDefault = true; + + # https://jvns.ca/blog/2024/02/16/popular-git-config-options/ programs.git.extraConfig.rerere.enabled = true; #programs.git.extraConfig.help.autocorrect = "prompt"; diff --git a/users/pbsds/home/profiles/update-diff.nix b/users/pbsds/home/profiles/update-diff.nix index 51e2b06..b5fcf73 100644 --- a/users/pbsds/home/profiles/update-diff.nix +++ b/users/pbsds/home/profiles/update-diff.nix @@ -1,12 +1,27 @@ { config, pkgs, ... }: { + # dix: https://github.com/faukah/dix + # rust based + # module from yolo + # nvd: https://discourse.nixos.org/t/nvd-simple-nix-nixos-version-diff-tool/12397 + # python based # module from https://infosec.exchange/@wyndon/110662698348958506 - home.activation.diff-update = config.lib.dag.entryAnywhere '' - if [[ -v oldGenPath ]]; then - ${pkgs.nvd}/bin/nvd diff $oldGenPath $newGenPath - fi - ''; + + home.activation.show-hm-closure-diff = config.lib.dag.entryAnywhere ( + if pkgs ? dix then + '' + if [[ -v oldGenPath ]]; then + ${pkgs.dix}/bin/dix $oldGenPath $newGenPath + fi + '' + else + '' + if [[ -v oldGenPath ]]; then + ${pkgs.nvd}/bin/nvd diff $oldGenPath $newGenPath + fi + '' + ); }