add zsh config

This commit is contained in:
jdonszelmann 2024-07-06 04:32:48 +02:00
parent 1da9036f7b
commit 527048be0c
No known key found for this signature in database
GPG key ID: E0C1EA36407B2FF2
11 changed files with 213 additions and 353 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake;

1
.gitignore vendored
View file

@ -0,0 +1 @@
.direnv

69
flake.lock generated
View file

@ -109,6 +109,24 @@
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
@ -236,6 +254,20 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1710377395,
"narHash": "sha256-KMubsUWtVr7L55pXMBibBDBdmk3xrjbBPduc0E8z28c=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "db001797591bf76f7b8d4c4ed3b49233391e0c97",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixvim": {
"inputs": {
"devshell": "devshell",
@ -268,7 +300,8 @@
"flake-utils": "flake-utils",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nixvim": "nixvim"
"nixvim": "nixvim",
"t": "t"
}
},
"systems": {
@ -301,6 +334,40 @@
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"t": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1710410762,
"narHash": "sha256-pCCCdoW4+ipCOwzJCYZJ8CNINDsQvACCaxh2xT6uqmw=",
"owner": "jdonszelmann",
"repo": "t-rs",
"rev": "1178091650351fc8372e4c84c786433f9bce69d5",
"type": "github"
},
"original": {
"owner": "jdonszelmann",
"repo": "t-rs",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [

View file

@ -11,40 +11,65 @@
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
t.url = "github:jdonszelmann/t-rs";
};
outputs = { self, home-manager, nixpkgs, flake-utils, nixvim }:
outputs = { self, home-manager, nixpkgs, flake-utils, nixvim, t }:
let
homeManagerModules = [ ];
homeManagerModules = [
nixvim.homeManagerModules.nixvim
];
pkgsForSystem = system:
import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
(final: prev: {
custom = {
inherit t;
};
})
];
};
mkHomeConfiguration = root: args:
home-manager.lib.homeManagerConfiguration (rec {
modules = [ root nixvim.homeManagerModules.nixvim ]
home-manager.lib.homeManagerConfiguration ({
modules = [ root ] ++ homeManagerModules
++ (args.modules or [ ]);
pkgs = pkgsForSystem (args.system or "x86_64-linux");
} // {
inherit (args) extraSpecialArgs;
});
homeConfigurations = {
kili = mkHomeConfiguration (import ./ori/home.nix) { extraSpecialArgs = { }; };
};
miscelaneous = {
inherit home-manager;
inherit (home-manager) packages;
};
in
flake-utils.lib.eachDefaultSystem
(system: rec {
formatter = legacyPackages.nixfmt;
legacyPackages = pkgsForSystem system;
pkgs = legacyPackages;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
(pkgs.writeShellScriptBin "fast-repl" ''
source /etc/set-environment
nix repl --file "${./.}/repl.nix" $@
'')
(pkgs.writeShellScriptBin "apply-home" ''
nix run .#home-manager -- switch --flake .#$@
'')
(pkgs.writeShellScriptBin "apply" ''
apply-home $(hostname -f)
'')
];
};
}) // {
inherit homeConfigurations;
} // miscelaneous;
homeConfigurations = {
kili = mkHomeConfiguration (import ./hosts/kili/home.nix) { extraSpecialArgs = { }; };
};
inherit home-manager;
inherit (home-manager) packages;
};
}

View file

@ -1,7 +1,10 @@
{ pkgs, ... }: {
{ ... }: {
home.stateVersion = "24.05";
home.username = "jonathan";
home.homeDirectory = "/home/jonathan";
imports = [ ../../programs/nvim ];
imports = [
../../programs/nvim
../../programs/zsh
];
}

View file

@ -1,6 +0,0 @@
```
nix run .#home-manager -- switch --flake .#<configuration>
```
(even on non-nixos systems. I use this config on archlinux)

View file

@ -160,7 +160,8 @@ in
runBuildScripts = true;
loadOutDirsFromCheck = true;
};
checkOnSave = {
checkOnSave = true;
check = {
allFeatures = true;
command = "clippy";
extraArgs = [ "--no-deps" ];

328
programs/nvim/flake.lock generated
View file

@ -1,328 +0,0 @@
{
"nodes": {
"devshell": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1717408969,
"narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=",
"owner": "numtide",
"repo": "devshell",
"rev": "1ebbe68d57457c8cae98145410b164b5477761f4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1717285511,
"narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"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-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"gitignore": "gitignore",
"nixpkgs": [
"nixvim",
"nixpkgs"
],
"nixpkgs-stable": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1718879355,
"narHash": "sha256-RTyqP4fBX2MdhNuMP+fnR3lIwbdtXhyj7w7fwtvgspc=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "8cd35b9496d21a6c55164d8547d9d5280162b07a",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"nixvim",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1719037157,
"narHash": "sha256-aOKd8+mhBsLQChCu1mn/W5ww79ta5cXVE59aJFrifM8=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "cd886711998fe5d9ff7979fdd4b4cbd17b1f1511",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"home-manager_2": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1718788307,
"narHash": "sha256-SqiOz0sljM0GjyQEVinPXQxaGcbOXw5OgpCWGPgh/vo=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "d7830d05421d0ced83a0f007900898bdcaf2a2ca",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1718662658,
"narHash": "sha256-AKG7BsqtVWDlefgzyKz7vjaKTLi4+bmTSBhowbQoZtM=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "29b3096a6e283d7e6779187244cb2a3942239fdf",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1719075281,
"narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixvim": {
"inputs": {
"devshell": "devshell",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"home-manager": "home-manager_2",
"nix-darwin": "nix-darwin",
"nixpkgs": [
"nixpkgs"
],
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1719042662,
"narHash": "sha256-xwj8hxu02myIPkNsch/v2NbxuRmuvlcphrbYPECE49c=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "49452662b7b4dd2467cbac19e0f9820d570d8976",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixvim",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nixvim": "nixvim"
}
},
"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"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1718522839,
"narHash": "sha256-ULzoKzEaBOiLRtjeY3YoGFJMwWSKRYOic6VNw2UyTls=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "68eb1dc333ce82d0ab0c0357363ea17c31ea1f81",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

81
programs/zsh/default.nix Normal file
View file

@ -0,0 +1,81 @@
{ pkgs, lib, ... }:
with builtins;
with lib.attrsets;
let
aliases = {
"p" = ((import ./scripts.nix) pkgs).calc;
"s" = "systemctl";
"j" = "journalctl";
"ju" = "journalctl -u";
"jfu" = "journalctl -fu";
"ls" = "${pkgs.eza}/bin/eza --git";
"ll" = "${pkgs.eza}/bin/eza --git";
"lt" = "${pkgs.eza}/bin/eza --long --tree -L 3";
"open" = "${pkgs.xdg-utils}/bin/xdg-open";
"clip" = "${pkgs.wl-clipboard-rs}/wl-copy";
};
# extracting any compressed format
extract = ''
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) ${pkgs.gnutar}/bin/tar xjf $1 ;;
*.tar.zst) ${pkgs.gnutar}/bin/tar --zstd xf $1 ;;
*.tar.gz) ${pkgs.gnutar}/bin/tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) ${pkgs.gnutar}/bin/tar xf $1 ;;
*.tbz2) ${pkgs.gnutar}/bin/tar xjf $1 ;;
*.tgz) ${pkgs.gnutar}/bin/tar xzf $1 ;;
*.zip) ${pkgs.unzip}/bin/unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.tar.xz) ${pkgs.gnutar}/bin/tar xJf $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
'';
in
{
programs.zsh = {
enable = true;
enableCompletion = true;
syntaxHighlighting.enable = true;
initExtra = ''
source "${pkgs.grml-zsh-config}/etc/zsh/zshrc"
export FZF_DEFAULT_COMMAND="${pkgs.ripgrep}/bin/rg --files --follow"
source "${pkgs.fzf}/share/fzf/key-bindings.zsh"
source "${pkgs.fzf}/share/fzf/completion.zsh"
eval "$(${pkgs.zoxide}/bin/zoxide init zsh)"
eval "$(${pkgs.atuin}/bin/atuin init zsh)"
eval "$(${pkgs.direnv}/bin/direnv hook zsh)"
${extract}
${foldl' (a: b: a + "\n" + b) ""
(mapAttrsToList (name: value: ''alias ${name}="${value}"'') aliases)}
function t() {
cd "$(${pkgs.custom.t}/bin/t-rs $@ | tail -n 1)"
}
function temp() {
t $@
}
# path
path() {
export PATH="$1:$PATH"
}
path "$HOME/.cargo/bin"
path "$HOME/.local/bin"
path "$HOME/Documents/scripts"
path "$HOME/.local/share/JetBrains/Toolbox/scripts"
'';
};
}

8
programs/zsh/scripts.nix Normal file
View file

@ -0,0 +1,8 @@
{ pkgs, ... }: {
calc = "${pkgs.python313}/bin/python -i ${
pkgs.writeText "init.py" ''
from math import *;
# import numpy as np
''
} ";
}

7
repl.nix Normal file
View file

@ -0,0 +1,7 @@
let
flake = builtins.getFlake (toString ./.);
nixpkgs = import <nixpkgs> { };
in
{
inherit flake;
} // flake // builtins // nixpkgs // nixpkgs.lib #// flake.nixosConfigurations