From 99c6bc4b6ff08ad7a1edaa0cff95e24e73cc84dd Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sun, 18 Feb 2024 22:14:40 +0100 Subject: [PATCH] swag --- base.nix | 4 ++-- flake.nix | 12 ++++++++-- justfile | 13 +++++++++-- profiles/desktop/flatpak.nix | 2 +- profiles/desktop/lutris.nix | 1 + users/pbsds/home/default.nix | 3 --- users/pbsds/home/profiles/bat.nix | 11 +++++---- users/pbsds/home/profiles/git.nix | 6 +++-- users/pbsds/home/profiles/shell.nix | 36 +++++++++++++++++++++++------ 9 files changed, 64 insertions(+), 24 deletions(-) diff --git a/base.nix b/base.nix index 5076372..c84c27c 100644 --- a/base.nix +++ b/base.nix @@ -59,8 +59,8 @@ # System fonts # Nice to have when X-forwading on headless machines fonts.fontDir.enable = true; # creates /run/current-system/sw/share/X11/fonts - fonts.enableDefaultFonts = true; # dejavu, freefont, gyre, liberation, unifont, noto-fonts-emoji - fonts.fonts = with pkgs; [ + fonts.enableDefaultPackages = true; # dejavu, freefont, gyre, liberation, unifont, noto-fonts-emoji + fonts.packages = with pkgs; [ noto-fonts # includes Cousine noto-fonts-cjk noto-fonts-emoji diff --git a/flake.nix b/flake.nix index 7505f7c..002537a 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,10 @@ home-manager-2305.url = "github:nix-community/home-manager/release-23.05"; home-manager-2305.inputs.nixpkgs.follows = "nixpkgs-2305"; + # https://github.com/nix-community/nix-index-database + nix-index-database.url = "github:Mic92/nix-index-database"; + nix-index-database.inputs.nixpkgs.follows = "nixpkgs-2311"; # only used for .packages + # https://github.com/NixOS/nixos-hardware nixos-hardware.url = "github:NixOS/nixos-hardware"; @@ -151,6 +155,7 @@ (ifExists "${self}/hosts/${hostname}") inputs.sops-nix.nixosModules.sops inputs.home-manager.nixosModule + #inputs.nix-index-database.nixosModules.nix-index ] ++ modules ++ extra-modules; #++ inputs.flake-programs-sqlite.nixosModules.programs-sqlite; # TODO: make work @@ -167,6 +172,7 @@ }; home-manager.sharedModules = [ inputs.sops-nix.homeManagerModules.sops + inputs.nix-index-database.hmModules.nix-index ]; # still needed even if using networkd @@ -212,8 +218,8 @@ in { inherit system; # TODO: cross system fqdn = cfg.networking.fqdn; - allowedTCPPorts = cfg.networking.firewall.allowedTCPPorts; - allowedUDPPorts = cfg.networking.firewall.allowedUDPPorts; + allowedTCPPorts = cfg.networking.firewall.allowedTCPPorts or []; + allowedUDPPorts = cfg.networking.firewall.allowedUDPPorts or []; bootloader = if cfg.boot.loader.grub.enable then "grub" else if cfg.boot.loader.systemd-boot.enable then "systemd-boot" else null; @@ -266,6 +272,7 @@ nixosModules = mkHosts (mkModule []); nixosConfigurations = mkHosts (mkConfig []); nixosReports = mkHosts (mkReport []); + nixosHostnames = builtins.attrNames self.nixosReports; # faster to eval packages = forAllSystems ({ inputs, pkgs, lib, flakes, ... }: let mk-nspawn-deployer = hostname: # TODO: nspawn-tarball.nix populates /etc/nixos with junk @@ -296,6 +303,7 @@ home.homeDirectory = home; home-manager.sharedModules = [ inputs.sops-nix.homeManagerModules.sops + inputs.nix-index-database.hmModules.nix-index ]; }]; extraSpecialArgs = { diff --git a/justfile b/justfile index acb8681..47b14bc 100644 --- a/justfile +++ b/justfile @@ -6,8 +6,14 @@ @set-remote: tomlq <.remote.toml '.hosts | to_entries[] | "remote-set \(.key+1) # -> \(.value.host)" | @sh "\(.)"' -r | xargs gum choose | sh -report: - nix eval .#nixosReports --json | yq . --yaml-output +eval hostname=`just _a-host`: + nix eval .#nixosConfigurations.{{hostname}}.config.system.build.toplevel.outPath + +report hostname=`just _a-host`: + nix eval .#nixosReports.{{hostname}} --json | yq . --yaml-output | bat --language yaml --style plain --paging never + +reports: + nix eval .#nixosReports --json | yq . --yaml-output | bat --language yaml --style plain --paging never update: git reset flake.lock @@ -32,3 +38,6 @@ boot: @list-remotes: echo Current remote: $(remote-host) tomlq <.remote.toml '.hosts | to_entries[] | "remote-set \(.key+1) # -> \(.value.host)"' -r + +@_a-host: + nix eval .#nixosHostnames --json 2>/dev/null | jq '.[]' -r | gum filter --height 10 --placeholder "Pick a host..." diff --git a/profiles/desktop/flatpak.nix b/profiles/desktop/flatpak.nix index b1ca947..8555dbf 100644 --- a/profiles/desktop/flatpak.nix +++ b/profiles/desktop/flatpak.nix @@ -21,7 +21,7 @@ }; aggregatedFonts = pkgs.buildEnv { name = "system-fonts"; - paths = config.fonts.fonts; + paths = config.fonts.packages; pathsToLink = [ "/share/fonts" ]; }; in { diff --git a/profiles/desktop/lutris.nix b/profiles/desktop/lutris.nix index edab7e6..c8b1ff6 100644 --- a/profiles/desktop/lutris.nix +++ b/profiles/desktop/lutris.nix @@ -9,6 +9,7 @@ (pkgs.lutris.override { extraPkgs = pkgs: [ pkgs.wineWowPackages.staging + pkgs.winetricks pkgs.pixman pkgs.libjpeg pkgs.gnome.zenity diff --git a/users/pbsds/home/default.nix b/users/pbsds/home/default.nix index 0235fd0..ca0897b 100644 --- a/users/pbsds/home/default.nix +++ b/users/pbsds/home/default.nix @@ -137,9 +137,6 @@ denix = "sed -E 's@/nix/store/[^ /]+@@g'"; }; - # TODO: auto-update db - programs.nix-index.enable = true; - xdg.enable = true; #TODO: xdg.desktopEntries diff --git a/users/pbsds/home/profiles/bat.nix b/users/pbsds/home/profiles/bat.nix index 7c14ee8..cdbe75a 100644 --- a/users/pbsds/home/profiles/bat.nix +++ b/users/pbsds/home/profiles/bat.nix @@ -13,14 +13,15 @@ # TODO: implement programs.bat.enableAliases programs.bat = { enable = true; - themes.railscast = builtins.readFile (pkgs.fetchFromGitHub { + #config.style = "plain"; + config.theme = "railscast"; + themes.railscast.file = "railscast-textmate.tmtheme"; + themes.railscast.src = pkgs.fetchFromGitHub { owner = "jeromedalbert"; repo = "sublime-text-railscasttextmate-theme"; - rev = "0a4861f35e72f9ad4cc1cac42730ea563be2ffd3"; + rev = "0a4861f35e72f9ad4cc1cac42730ea563be2ffd3"; # 11 years old hash = "sha256-1Ml5vqP9r6oCfLhaNGPQJXS8e7utxQQycIm3Hk9wE3w="; - } + "/railscast-textmate.tmtheme"); - config.theme = "railscast"; - #config.style = "plain"; + }; config.map-syntax = [ "poetry.toml:toml" "flake.lock:json" diff --git a/users/pbsds/home/profiles/git.nix b/users/pbsds/home/profiles/git.nix index 8891748..8b3915f 100644 --- a/users/pbsds/home/profiles/git.nix +++ b/users/pbsds/home/profiles/git.nix @@ -1,12 +1,14 @@ { pkgs, ... }: { home.packages = with pkgs; [ - git - gh + #git + #gh hub colordiff ]; + programs.gh.enable = true; + #programs.git.gitui.enable = true; programs.git.enable = true; programs.git.delta.enable = true; diff --git a/users/pbsds/home/profiles/shell.nix b/users/pbsds/home/profiles/shell.nix index 719725c..9546ff3 100644 --- a/users/pbsds/home/profiles/shell.nix +++ b/users/pbsds/home/profiles/shell.nix @@ -32,19 +32,29 @@ imports = [ ../modules/jump.nix ]; programs.jump.enableBash = true; # TODO: upstream? + programs.nix-index.enable = true; + programs.nix-index-database.comma.enable = true; # via nix-index-database flake + #programs.command-not-found.enable = false; # mutex with nix-index + programs.fzf.enable = true; # TODO: does this conflict with system-wide setup? - programs.exa.enable = true; - programs.exa.enableAliases = true; + programs.eza.enable = true; + programs.eza.enableAliases = true; + + programs.zoxide.enable = true; + programs.zoxide.options = [ "--cmd cd --cmd dc" ]; + + programs.carapace.enable = true; # i can't type - home.shellAliases.sl = "exa"; - home.shellAliases.dc = "cd"; + home.shellAliases.sl = "eza"; + #home.shellAliases.dc = "cd"; programs.direnv.enable = true; - #programs.direnv.nix-direnv.enable = true; + programs.direnv.nix-direnv.enable = true; programs.tealdeer.enable = true; + programs.tealdeer.settings.updates.auto_update = true; # just use ncdu lol @@ -60,12 +70,23 @@ home.shellAliases.watch = "watch -c "; # parse colors home.shellAliases.xargs = "xargs "; + # Be conservative with files + # --preserver-root is for GNU versions + # do not delete / or prompt if deleting more than 3 files at a time + home.shellAliases.rm = "rm -i --preserve-root"; + home.shellAliases.mv = "mv -i"; + home.shellAliases.cp = "cp -i"; + # Preventing changing perms on / + home.shellAliases.chown = "chown --preserve-root"; + home.shellAliases.chmod = "chmod --preserve-root"; + home.shellAliases.chgrp = "chgrp --preserve-root"; + + home.packages = with pkgs; [ rsync bind.dnsutils # dig dogdns # dog vimv - git curl wget @@ -90,9 +111,10 @@ gum sysz du-dust # du alternative + duf # df alternative ncdu # Disk usage analyzer with an ncurses interface xplr # tui file explorer - aha unstable.colorized-logs + aha (pkgs.colorized-logs or unstable.colorized-logs) ]; }