Skip to content

Instantly share code, notes, and snippets.

View 573's full-sized avatar

Daniel Kahlenberg 573

View GitHub Profile
@573
573 / readme.md
Created May 31, 2024 14:51
postgres postgresql psql nix shell nixpkgs

nix shell nixpkgs#postgresql -c psql -h ipaddress -U username -d dbname

@573
573 / readme.md
Created May 25, 2024 13:09
garbage collect delete old nix
cd /home/nixos/.nix-config/
nix run .#nixosConfigurations.DANIELKNB1.pkgs.home-manager.out -- expire-generations "$(date)"
nix-store --gc --print-roots | egrep -v "^(/nix/var|/run/\w+-system|\{memory|/proc)" | awk '{ print $1 }' | grep -vE 'home-manager|flake-registry\.json'
@573
573 / readme.md
Last active May 24, 2024 09:56
nix emacs WIP: meaning of epkgs why can't I extract the emacs packages list

nix-repl> :lf nixpkgs
Added 15 variables.
nix-repl> :t legacyPackages.x86_64-linux.emacs.pkgs.withPackages
a function

@573
573 / readme.md
Last active May 23, 2024 14:38
nix tip: have function applicated as type
nix-repl> f = e: []

nix-repl> :t f
a function

nix-repl> :t (f {})
a list

f can be any lambda as well.

@573
573 / readme.md
Created May 22, 2024 15:54
libreoffice tip: export redacted pdf

extras > redigieren > export red. pdf

@573
573 / readme.md
Last active May 23, 2024 13:52
nix tip: use flake flakes v3 eval to show list(s) of available attributes in given set(s)
  • see https://github.com/spikespaz/dotfiles: i. e. nix eval 'github:spikespaz/dotfiles#nixosModules' --apply 'builtins.attrNames' (set nixosModules)
  • nix eval .#devShells.aarch64-linux --apply 'builtins.attrNames'
  • nix eval .#nixosConfigurations.DANIELKNB1.config.virtualisation.docker --apply 'builtins.attrNames' and with result list item nix eval --raw .#nixosConfigurations.DANIELKNB1.config.virtualisation.docker.package
  • nix eval --json .#nixosConfigurations.DANIELKNB1.config.hardware.nvidia-container-toolkit.enable
  • nix eval github:nix-community/home-manager#lib.hm --apply 'builtins.attrNames'
  • nix eval nixpkgs#lib.types.types --apply 'builtins.attrNames'
@573
573 / readme.md
Created May 22, 2024 12:51
nix tip: use pull request pr in flake flakes uri url

i. e. url = "github:nix-community/nixos-wsl?ref=refs/pull/478/head";

@573
573 / readme.md
Last active May 21, 2024 12:32
lua prototyping with a nix flake
nix develop --impure --expr 'let pkgs = import (builtins.getFlake "nixpkgs/master") {}; in pkgs.mkShell { buildInputs = with pkgs; [ lua luaPackages.http ]; }'
> ht = require'http.util'
> print(ht.dict_to_query({foo = "bar"; baz = "qux"})) --> "baz=qux&foo=bar"
baz=qux&foo=bar

https://discourse.nixos.org/t/using-nix-run-with-several-packages/25177/2

when master is not needed: