From 81fc7d3461a1c2e39814067d2bc773a684f2e444 Mon Sep 17 00:00:00 2001 From: iFargle Date: Fri, 30 Jun 2023 14:08:28 +0900 Subject: [PATCH] Testing nix flakes --- laptop/configuration.nix | 21 ++++- laptop/home-manager/dotfiles/git.nix | 134 +++++++++++++++++++++++++++ laptop/home-manager/dotfiles/vim.nix | 25 +++++ laptop/home-manager/flake.nix | 26 ++++++ laptop/home-manager/home.nix | 4 + 5 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 laptop/home-manager/dotfiles/git.nix create mode 100644 laptop/home-manager/dotfiles/vim.nix create mode 100644 laptop/home-manager/flake.nix create mode 100644 laptop/home-manager/home.nix diff --git a/laptop/configuration.nix b/laptop/configuration.nix index 2cbe5d81..f1f39002 100644 --- a/laptop/configuration.nix +++ b/laptop/configuration.nix @@ -7,6 +7,9 @@ # NixOS Packages / Options: # https://search.nixos.org/packages? +# Other things to consider: +# Telegraf + { config, pkgs, ... }: { imports = [ @@ -100,6 +103,15 @@ videoDrivers = [ "nvidia" ]; autorun = true; }; + + # Enable nVidia PRIME Render Offload + # https://github.com/NixOS/nixos-hardware/blob/master/lenovo/thinkpad/p1/3th-gen/nvidia.nix + hardware.nvidia.prime = { + # Bus ID of the Intel GPU. + intelBusId = lib.mkDefault "PCI:0:2:0"; + # Bus ID of the NVIDIA GPU. + nvidiaBusId = lib.mkDefault "PCI:1:0:0"; + }; # Enable sound with pipewire. sound.enable = true; @@ -127,9 +139,16 @@ ]; }; - # Allow unfree packages + # Allow unfree packages nixpkgs.config.allowUnfree = true; + # Enable flakes: https://nixos.wiki/wiki/Flakes + nix = { + package = pkgs.nixFlakes; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ diff --git a/laptop/home-manager/dotfiles/git.nix b/laptop/home-manager/dotfiles/git.nix new file mode 100644 index 00000000..ce89bde6 --- /dev/null +++ b/laptop/home-manager/dotfiles/git.nix @@ -0,0 +1,134 @@ +{ + programs.git = { + enable = true; + userName = "albert"; + userEmail = "albert@sysctl.io"; + extraConfig = { + credential.helper = "cache --timeout=25920000"; + alias.a = "add --all"; + alias.ai = "add -i"; + alias.ap = "apply"; + alias.as = "apply --stat"; + alias.ac = "apply --check"; + alias.ama = "am --abort"; + alias.amr = "am --resolved"; + alias.ams = "am --skip"; + alias.b = "branch"; + alias.ba = "branch -a"; + alias.bd = "branch -d"; + alias.bdd = "branch -D"; + alias.br = "branch -r"; + alias.bc = "rev-parse --abbrev-ref HEAD"; + alias.c = "commit"; + alias.ca = "commit -a"; + alias.cm = "commit -m"; + alias.cam = "commit -am"; + alias.cem = "commit --allow-empty -m"; + alias.cd = "commit --amend"; + alias.cad = "commit -a --amend"; + alias.ced = "commit --allow-empty --amend"; + alias.cl = "clone"; + alias.cld = "clone --depth 1"; + alias.cp = "cherry-pick"; + alias.cpa = "cherry-pick --abort"; + alias.cpc = "cherry-pick --continue"; + alias.d = "diff"; + alias.dp = "diff --patience"; + alias.dc = "diff --cached"; + alias.dk = "diff --check"; + alias.dck = "diff --cached --check"; + alias.dt = "difftool"; + alias.dct = "difftool --cached"; + alias.f = "fetch"; + alias.fo = "fetch origin"; + alias.fu = "fetch upstream"; + alias.fp = "format-patch"; + alias.fk = "fsck"; + alias.g = "grep -p"; + alias.l = "log --oneline"; + alias.lg = "log --oneline --graph --decorate"; + alias.ls = "ls-files"; + alias.lsf = "!git ls-files | grep -i"; + alias.m = "merge"; + alias.ma = "merge --abort"; + alias.mc = "merge --continue"; + alias.ms = "merge --skip"; + alias.o = "checkout"; + alias.ob = "checkout -b"; + alias.pr = "prune -v"; + alias.ps = "push"; + alias.psf = "push -f"; + alias.psu = "push -u"; + alias.pst = "push --tags"; + alias.pso = "push origin"; + alias.psao = "push --all origin"; + alias.psfo = "push -f origin"; + alias.psuo = "push -u origin"; + alias.psom = "push origin master"; + alias.psaom = "push --all origin master"; + alias.psfom = "push -f origin master"; + alias.psuom = "push -u origin master"; + alias.psoc = "!git push origin $(git bc)"; + alias.psaoc = "!git push --all origin $(git bc)"; + alias.psfoc = "!git push -f origin $(git bc)"; + alias.psuoc = "!git push -u origin $(git bc)"; + alias.psdc = "!git push origin :$(git bc)"; + alias.pl = "pull"; + alias.pb = "pull --rebase"; + alias.plo = "pull origin"; + alias.pbo = "pull --rebase origin"; + alias.plom = "pull origin master"; + alias.ploc = "!git pull origin $(git bc)"; + alias.pbom = "pull --rebase origin master"; + alias.pboc = "!git pull --rebase origin $(git bc)"; + alias.plu = "pull upstream"; + alias.plum = "pull upstream master"; + alias.pluc = "!git pull upstream $(git bc)"; + alias.pbum = "pull --rebase upstream master"; + alias.pbuc = "!git pull --rebase upstream $(git bc)"; + alias.rb = "rebase"; + alias.rba = "rebase --abort"; + alias.rbc = "rebase --continue"; + alias.rbi = "rebase --interactive"; + alias.rbs = "rebase --skip"; + alias.re = "reset"; + alias.rh = "reset HEAD"; + alias.reh = "reset --hard"; + alias.rem = "reset --mixed"; + alias.res = "reset --soft"; + alias.rehh = "reset --hard HEAD"; + alias.remh = "reset --mixed HEAD"; + alias.resh = "reset --soft HEAD"; + alias.r = "remote"; + alias.ra = "remote add"; + alias.rr = "remote rm"; + alias.rv = "remote -v"; + alias.rn = "remote rename"; + alias.rp = "remote prune"; + alias.rs = "remote show"; + alias.rao = "remote add origin"; + alias.rau = "remote add upstream"; + alias.rro = "remote remove origin"; + alias.rru = "remote remove upstream"; + alias.rso = "remote show origin"; + alias.rsu = "remote show upstream"; + alias.rpo = "remote prune origin"; + alias.rpu = "remote prune upstream"; + alias.rmf = "rm -f"; + alias.rmrf = "rm -r -f"; + alias.s = "status"; + alias.sb = "status -s -b"; + alias.sa = "stash apply"; + alias.sc = "stash clear"; + alias.sd = "stash drop"; + alias.sl = "stash list"; + alias.sp = "stash pop"; + alias.ss = "stash save"; + alias.sw = "stash show"; + alias.t = "tag"; + alias.td = "tag -d"; + alias.w = "show"; + alias.wp = "show -p"; + alias.wr = "show -p --no-color"; + }; +} \ No newline at end of file diff --git a/laptop/home-manager/dotfiles/vim.nix b/laptop/home-manager/dotfiles/vim.nix new file mode 100644 index 00000000..c63ffd14 --- /dev/null +++ b/laptop/home-manager/dotfiles/vim.nix @@ -0,0 +1,25 @@ +{ + environment.systemPackages = [ + (pkgs.vim_configurable.customize { + vimrcConfig.customRc = '' + set nocompatible + filetype on + syntax on + set number + set cursorline + set cursorcolumn + set nowrap + set expandtab + set tabstop=2 + set shiftwidth=2 + set incsearch + set ignorecase + set hlsearch + set history=1000 + set wildmenu + set wildmode=list:longest + set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx + ''; + }) + ]; +} \ No newline at end of file diff --git a/laptop/home-manager/flake.nix b/laptop/home-manager/flake.nix new file mode 100644 index 00000000..414dc733 --- /dev/null +++ b/laptop/home-manager/flake.nix @@ -0,0 +1,26 @@ +{ + description = "NixOS configuration"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; + home-manager.url = "github:nix-community/home-manager/release-23.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = inputs@{ nixpkgs, home-manager, ... }: { + nixosConfigurations = { + hostname = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = false; + home-manager.users.albert = import ./home.nix; + } + ]; + }; + }; + }; +} \ No newline at end of file diff --git a/laptop/home-manager/home.nix b/laptop/home-manager/home.nix new file mode 100644 index 00000000..c7e32dfc --- /dev/null +++ b/laptop/home-manager/home.nix @@ -0,0 +1,4 @@ + imports = [ + ./dotfiles/git.nix + ./dotfiles/vim.nix + ]; \ No newline at end of file