1 Commits

Author SHA1 Message Date
fca998e14c add ssl certs for darwin even though it didn't work 2022-09-21 16:25:16 -04:00
168 changed files with 1501 additions and 5165 deletions

3
.gitignore vendored
View File

@ -4,6 +4,3 @@
**/.direnv/** **/.direnv/**
result result
.luarc.json .luarc.json
private/**
!private/**.age
!private/**.sha512

View File

@ -1,33 +1,6 @@
This repository contains configuration files for my NixOS, macOS, and WSL This repository contains configuration files for my NixOS, macOS, and WSL
hosts. hosts.
They are organized and managed by [Nix](https://nixos.org), so some of the
configuration may be difficult to translate to a non-Nix system.
However, some of the configurations are easier to lift directly:
- [Neovim](https://github.com/nmasur/dotfiles/tree/master/modules/neovim/config)
- [Fish functions](https://github.com/nmasur/dotfiles/tree/master/modules/shell/fish/functions)
- [More fish aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/fish/default.nix)
- [Git aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/git.nix)
- [Hammerspoon](https://github.com/nmasur/dotfiles/tree/master/modules/darwin/hammerspoon)
Try out my Neovim config:
```bash
nix run github:nmasur/dotfiles#neovim
```
Or build it as a package:
```bash
nix build github:nmasur/dotfiles#neovim
```
If you already have a Neovim configuration, you may need to move it out of
`~/.config/nvim` or set `XDG_CONFIG_HOME` to another value; otherwise, both
configs might conflict with each other.
--- ---
# Installation # Installation
@ -41,7 +14,7 @@ installer disk:
```bash ```bash
lsblk # Choose the disk you want to wipe lsblk # Choose the disk you want to wipe
nix-shell -p nixVersions.stable nix-shell -p nixFlakes
nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop
``` ```
@ -51,7 +24,7 @@ If you're already running NixOS, you can switch to this configuration with the
following command: following command:
```bash ```bash
nix-shell -p nixVersions.stable nix-shell -p nixFlakes
sudo nixos-rebuild switch --flake github:nmasur/dotfiles#desktop sudo nixos-rebuild switch --flake github:nmasur/dotfiles#desktop
``` ```
@ -62,16 +35,10 @@ WSL](https://xeiaso.net/blog/nix-flakes-4-wsl-2022-05-01), you can switch to
the WSL configuration: the WSL configuration:
``` ```
nix-shell -p nixVersions.stable nix-shell -p nixFlakes
sudo nixos-rebuild switch --flake github:nmasur/dotfiles#wsl sudo nixos-rebuild switch --flake github:nmasur/dotfiles#wsl
``` ```
You should also download the
[FiraCode](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/FiraCode.zip)
font and install it on Windows. Install [Alacritty](https://alacritty.org/) and
move the `windows/alacritty.yml` file to
`C:\Users\<user>\AppData\Roaming\alacritty`.
## macOS ## macOS
To get started on a bare macOS installation, first install Nix: To get started on a bare macOS installation, first install Nix:
@ -103,6 +70,12 @@ openssl s_client -showcerts -verify 5 -connect cache.nixos.org:443 < /dev/null
sudo nvim $NIX_SSL_CERT_FILE sudo nvim $NIX_SSL_CERT_FILE
``` ```
### Dealing with Neovim issues:
Update Neovim Packer plugins: `:PackerSync`
Update TreeSitter languages: `:TSUpdateSync`
--- ---
# Flake Templates # Flake Templates

View File

@ -1,70 +0,0 @@
{ pkgs, ... }: rec {
default = {
type = "app";
program = builtins.toString (pkgs.writeShellScript "default" ''
${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options"
${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.'
echo ""
echo ""
${pkgs.gum}/bin/gum format --type=template -- \
' {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \
' {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \
' {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \
' {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \
' {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \
' {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \
' {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \
' {{ Color "15" "57" " netdata " }} {{ Italic "Connect a machine to Netdata cloud." }}'
echo ""
echo ""
'');
};
# Format and install from nothing
installer = import ./installer.nix { inherit pkgs; };
# Display the readme for this repository
readme = import ./readme.nix { inherit pkgs; };
# Rebuild
rebuild = {
type = "app";
program = builtins.toString (pkgs.writeShellScript "rebuild" ''
echo ${pkgs.system}
SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"}
if [ "$SYSTEM" == "darwin" ]; then
darwin-rebuild switch --flake github:nmasur/dotfiles#macbook
else
nixos-rebuild switch --flake github:nmasur/dotfiles
fi
'');
};
# Load the SSH key for this machine
loadkey = import ./loadkey.nix { inherit pkgs; };
# Encrypt secret for all machines
encrypt-secret = import ./encrypt-secret.nix { inherit pkgs; };
# Re-encrypt secrets for all machines
reencrypt-secrets = import ./reencrypt-secrets.nix { inherit pkgs; };
# Connect machine metrics to Netdata Cloud
netdata = import ./netdata-cloud.nix { inherit pkgs; };
# Run neovim as an app
neovim = {
type = "app";
program = "${
(import ../modules/neovim/package {
inherit pkgs;
colors =
import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; };
})
}/bin/nvim";
};
nvim = neovim;
}

View File

@ -1,19 +0,0 @@
{ pkgs, ... }: {
# nix run github:nmasur/dotfiles#encrypt-secret > private/mysecret.age
type = "app";
program = builtins.toString (pkgs.writeShellScript "encrypt-secret" ''
printf "\nEnter the secret data to encrypt for all hosts...\n\n" 1>&2
read -p "Secret: " secret
printf "\nEncrypting...\n\n" 1>&2
tmpfile=$(mktemp)
echo "''${secret}" > ''${tmpfile}
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${
builtins.toString ../hosts/public-keys
} $tmpfile
rm $tmpfile
'');
}

View File

@ -13,12 +13,10 @@
PARTITION_PREFIX="" PARTITION_PREFIX=""
if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then
${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \ echo "Missing required parameter."
--foreground "#fb4934" \ echo "Usage: installer -- <disk> <host>"
"Missing required parameter." \ echo "Example: installer -- nvme0n1 desktop"
"Usage: installer -- <disk> <host>" \ echo "Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop"
"Example: installer -- nvme0n1 desktop" \
"Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop"
echo "(exiting)" echo "(exiting)"
exit 1 exit 1
fi fi
@ -27,14 +25,10 @@
PARTITION_PREFIX="p" PARTITION_PREFIX="p"
esac esac
${pkgs.gum}/bin/gum confirm \ parted /dev/''${DISK} -- mklabel gpt
"This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \ parted /dev/''${DISK} -- mkpart primary 512MiB 100%
--default=false parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
parted /dev/''${DISK} -- set 3 esp on
${pkgs.parted}/bin/parted /dev/''${DISK} -- mklabel gpt
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart primary 512MiB 100%
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
${pkgs.parted}/bin/parted /dev/''${DISK} -- set 3 esp on
mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1 mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1
mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2 mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2
@ -42,7 +36,7 @@
mkdir --parents /mnt/boot mkdir --parents /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot mount /dev/disk/by-label/boot /mnt/boot
${pkgs.nixos-install-tools}/bin/nixos-install --flake github:nmasur/dotfiles#''${FLAKE} nixos-install --flake github:nmasur/dotfiles#''${FLAKE}
''); '');
} }

View File

@ -1,12 +0,0 @@
{ pkgs, ... }: {
type = "app";
program = builtins.toString (pkgs.writeShellScript "loadkey" ''
printf "\nEnter the seed phrase for your SSH key...\n"
printf "\nThen press ^D when complete.\n\n"
${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519
printf "\n\nContinuing activation.\n\n"
'');
}

View File

@ -1,19 +0,0 @@
{ pkgs, ... }: {
type = "app";
program = builtins.toString (pkgs.writeShellScript "netdata-cloud" ''
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
mkdir --parents --mode 0750 /var/lib/netdata/cloud.d
printf "\nEnter the claim token for netdata cloud...\n\n"
read -p "Token: " token
echo "''${token}" > /var/lib/netdata/cloud.d/token
chown -R netdata:netdata /var/lib/netdata
${pkgs.netdata}/bin/netdata-claim.sh -id=$(uuidgen)
printf "\n\nNow restart netdata service.\n\n"
'');
}

View File

@ -3,7 +3,7 @@
type = "app"; type = "app";
program = builtins.toString (pkgs.writeShellScript "readme" '' program = builtins.toString (pkgs.writeShellScript "readme" ''
${pkgs.glow}/bin/glow --pager ${builtins.toString ../README.md} ${pkgs.glow}/bin/glow ${builtins.toString ../README.md}
''); '');
} }

View File

@ -1,27 +0,0 @@
{ pkgs, ... }: {
# nix run github:nmasur/dotfiles#reencrypt-secrets ./private
type = "app";
program = builtins.toString (pkgs.writeShellScript "reencrypt-secrets" ''
if [ $# -eq 0 ]; then
echo "Must provide directory to reencrypt."
exit 1
fi
encrypted=$1
for encryptedfile in ''${1}/*; do
tmpfile=$(mktemp)
echo "Decrypting ''${encryptedfile}..."
${pkgs.age}/bin/age --decrypt \
--identity ~/.ssh/id_ed25519 $encryptedfile > $tmpfile
echo "Encrypting ''${encryptedfile}..."
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${
builtins.toString ../hosts/public-keys
} $tmpfile > $encryptedfile
rm $tmpfile
done
echo "Finished."
'');
}

View File

@ -1,45 +0,0 @@
{
name = "gruvbox"; # Dark, Medium
author =
"Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)";
dark = {
base00 = "#282828"; # ----
base01 = "#3c3836"; # ---
base02 = "#504945"; # --
base03 = "#665c54"; # -
base04 = "#bdae93"; # +
base05 = "#d5c4a1"; # ++
base06 = "#ebdbb2"; # +++
base07 = "#fbf1c7"; # ++++
base08 = "#fb4934"; # red
base09 = "#fe8019"; # orange
base0A = "#fabd2f"; # yellow
base0B = "#b8bb26"; # green
base0C = "#8ec07c"; # aqua/cyan
base0D = "#83a598"; # blue
base0E = "#d3869b"; # purple
base0F = "#d65d0e"; # brown
neovimConfig = ./neovim-gruvbox.nix;
batTheme = "gruvbox-dark";
};
light = {
base00 = "#fbf1c7"; # ----
base01 = "#ebdbb2"; # ---
base02 = "#d5c4a1"; # --
base03 = "#bdae93"; # -
base04 = "#665c54"; # +
base05 = "#504945"; # ++
base06 = "#3c3836"; # +++
base07 = "#282828"; # ++++
base08 = "#9d0006"; # red
base09 = "#af3a03"; # orange
base0A = "#b57614"; # yellow
base0B = "#79740e"; # green
base0C = "#427b58"; # aqua/cyan
base0D = "#076678"; # blue
base0E = "#8f3f71"; # purple
base0F = "#d65d0e"; # brown
neovimConfig = ./neovim-gruvbox.nix;
batTheme = "gruvbox-light";
};
}

View File

@ -1,12 +0,0 @@
{ pkgs, ... }: {
plugins = [ pkgs.vimPlugins.vim-gruvbox8 ];
vim.g.gruvbox_italicize_strings = 0;
vim.o.background = "dark";
vimscript = ''
let g:gruvbox_italicize_strings = 0
colorscheme gruvbox8
'';
}

419
flake.lock generated
View File

@ -1,53 +1,5 @@
{ {
"nodes": { "nodes": {
"Comment-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1668781964,
"narHash": "sha256-po1MyuuOH3e8yJTAtkxnusFSJuNpQnjpe+zfWPoO62E=",
"owner": "numToStr",
"repo": "Comment.nvim",
"rev": "5f01c1a89adafc52bf34e3bf690f80d9d726715d",
"type": "github"
},
"original": {
"owner": "numToStr",
"repo": "Comment.nvim",
"type": "github"
}
},
"bufferline-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1668632062,
"narHash": "sha256-qGl1jwBaMFWsrth7F20KrfJpyVENF8GEOJsVBBcSTVA=",
"owner": "akinsho",
"repo": "bufferline.nvim",
"rev": "4ecfa81e470a589e74adcde3d5bb1727dd407363",
"type": "github"
},
"original": {
"owner": "akinsho",
"repo": "bufferline.nvim",
"type": "github"
}
},
"cmp-nvim-lsp-src": {
"flake": false,
"locked": {
"lastModified": 1668566979,
"narHash": "sha256-Mqkp8IH/laUx0cK7S0BjusTT+OtOOJOamZM4+93RHdU=",
"owner": "hrsh7th",
"repo": "cmp-nvim-lsp",
"rev": "59224771f91b86d1de12570b4070fe4ad7cd1eeb",
"type": "github"
},
"original": {
"owner": "hrsh7th",
"repo": "cmp-nvim-lsp",
"type": "github"
}
},
"darwin": { "darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -55,11 +7,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1671196037, "lastModified": 1662478528,
"narHash": "sha256-2+J98SeczFWonbqFLMEAQC7vZEe6I2gM17XYvEmG52I=", "narHash": "sha256-Myjd0HPL5lXri3NXOcJ6gP7IKod2eMweQBKM4uxgEGw=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "adb8ac0453c8b2c40f5bffb578453dbaee838952", "rev": "3b69bf3cc26ae19de847bfe54d6ab22d7381a90a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -69,32 +21,14 @@
"type": "github" "type": "github"
} }
}, },
"firefox-darwin": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1671410692,
"narHash": "sha256-azBs+c7zMnjNXntsnFM67AKsTdlUhU4eFzZwtTEGScs=",
"owner": "bandithedoge",
"repo": "nixpkgs-firefox-darwin",
"rev": "ce6bde60382284ca3044b4010143fec0c44a3cf5",
"type": "github"
},
"original": {
"owner": "bandithedoge",
"repo": "nixpkgs-firefox-darwin",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1668681692, "lastModified": 1650374568,
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "009399224d5e398d03b22badca40a37ac85412a1", "rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -104,21 +38,6 @@
} }
}, },
"flake-utils": { "flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
@ -133,21 +52,6 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_3": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -156,11 +60,11 @@
"utils": "utils" "utils": "utils"
}, },
"locked": { "locked": {
"lastModified": 1671459164, "lastModified": 1663328500,
"narHash": "sha256-RbkDnvLV7WjbiF4Dpiezrf8kXxwieQXAVtY8ciRQj6Q=", "narHash": "sha256-7n+J/exp8ky4dmk02y5a9R7CGmJvHpzrHMzfEkMtSWA=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "e7eba9cc46547ae86642ad3c6a9a4fb22c07bc26", "rev": "5427f3d1f0ea4357cd4af0bffee7248d640c6ffc",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -170,122 +74,13 @@
"type": "github" "type": "github"
} }
}, },
"nil": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1670595719,
"narHash": "sha256-9jvA0QdcZtGWImiRZ8KRhXNsy5NxgZBm0TXtNLmFbyM=",
"owner": "oxalica",
"repo": "nil",
"rev": "1c122ae707c6365ea731565daf307844df03e95e",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "nil",
"type": "github"
}
},
"nix2vim": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1671522211,
"narHash": "sha256-i5BLrj3wlIC1VMQTfBSYIasEmv3D4as0Mu2K3rdJrSU=",
"owner": "gytis-ivaskevicius",
"repo": "nix2vim",
"rev": "3cc95ef557b6e2f97f5ff14ae89997a564d3a130",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"repo": "nix2vim",
"type": "github"
}
},
"nixlib": {
"locked": {
"lastModified": 1636849918,
"narHash": "sha256-nzUK6dPcTmNVrgTAC1EOybSMsrcx+QrVPyqRdyKLkjA=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "28a5b0557f14124608db68d3ee1f77e9329e9dd5",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixos-generators": {
"inputs": {
"nixlib": "nixlib",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1671355134,
"narHash": "sha256-ZtnUWTDDyFog+NQBjZpnhgPdj3gHp5ImxFVWy+ObNno=",
"owner": "nix-community",
"repo": "nixos-generators",
"rev": "64a96ca8621d03cb3889daf0d3ff58d8209e3e0c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-generators",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1639237670, "lastModified": 1663357389,
"narHash": "sha256-RTdL4rEQcgaZGpvtDgkp3oK/V+1LM3I53n0ACPSroAQ=", "narHash": "sha256-oYA2nVRSi6yhCBqS5Vz465Hw+3BQOVFEhfbfy//3vTs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "edfb969386ebe6c3cf8f878775a7975cd88f926d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "master",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1670559856,
"narHash": "sha256-xUkgQRFqE6HIFQXs9SIXMZiXcLaH2415UR6w/FnsgcY=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6bc6f77cb171a74001033d94f17f49043a9f1804", "rev": "da6a05816e7fa5226c3f61e285ef8d9dfc868f3c",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1671359686,
"narHash": "sha256-3MpC6yZo+Xn9cPordGz2/ii6IJpP2n8LE8e/ebUXLrs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "04f574a1c0fde90b51bf68198e2297ca4e7cccf4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -295,45 +90,28 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_4": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1671313200, "lastModified": 1660318005,
"narHash": "sha256-itZTrtHeDJjV696+ur0/TzkTqb5y3Eb57WRLRPK3rwA=", "narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "0938d73bb143f4ae037143572f11f4338c7b2d1c", "rev": "5c211b47aeadcc178c5320afd4e74c7eed5c389f",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "id": "nixpkgs",
"ref": "nixos-22.11", "ref": "nixos-22.05",
"repo": "nixpkgs", "type": "indirect"
"type": "github"
}
},
"null-ls-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1671458255,
"narHash": "sha256-YQaWKSW9D1HEBva9GeivQkylFeYfTrFUiTkXYF4V8SA=",
"owner": "jose-elias-alvarez",
"repo": "null-ls.nvim",
"rev": "db1c7cb5f6d6f6036b7f8433bb3cfcbe985cb3d1",
"type": "github"
},
"original": {
"owner": "jose-elias-alvarez",
"repo": "null-ls.nvim",
"type": "github"
} }
}, },
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1671547500, "lastModified": 1663440270,
"narHash": "sha256-97hzIBBNDbva9eRj1WomM+pimxt7hVrH/yNjUfJSMJc=", "narHash": "sha256-RkBoLyxamsBqRn9lB9RbFSDg7KHiGgHBsrpffEVXWCQ=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nur", "repo": "nur",
"rev": "4103fbdf825891b4dc54a6bda72ef1757081444c", "rev": "7511d58da488c67887745f40fd4846aa8c876d25",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -342,158 +120,23 @@
"type": "github" "type": "github"
} }
}, },
"nvim-lspconfig-src": {
"flake": false,
"locked": {
"lastModified": 1671517641,
"narHash": "sha256-RWXc/nCVNPv0BQN99QQMfeplQFpEsNJdmyoC/TQuIYQ=",
"owner": "neovim",
"repo": "nvim-lspconfig",
"rev": "d597b0f3605f43526f1b6948c6d7ca2919ea32ac",
"type": "github"
},
"original": {
"owner": "neovim",
"repo": "nvim-lspconfig",
"type": "github"
}
},
"nvim-tree-lua-src": {
"flake": false,
"locked": {
"lastModified": 1671430707,
"narHash": "sha256-SdQ7nCgrtSN96XeaPjDoGnc++jllYy/up/jDc5LunRM=",
"owner": "kyazdani42",
"repo": "nvim-tree.lua",
"rev": "e14c2895b4f36a22001f7773244041c173dcf867",
"type": "github"
},
"original": {
"owner": "kyazdani42",
"repo": "nvim-tree.lua",
"type": "github"
}
},
"nvim-treesitter-src": {
"flake": false,
"locked": {
"lastModified": 1671521720,
"narHash": "sha256-GeuRomX3cFXK/zqWf1SJ3WXbTSLLy3FT99lIyhVnefo=",
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"rev": "eedb7b9c69b13afe86461b0742266bb62b811ece",
"type": "github"
},
"original": {
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"Comment-nvim-src": "Comment-nvim-src",
"bufferline-nvim-src": "bufferline-nvim-src",
"cmp-nvim-lsp-src": "cmp-nvim-lsp-src",
"darwin": "darwin", "darwin": "darwin",
"firefox-darwin": "firefox-darwin",
"home-manager": "home-manager", "home-manager": "home-manager",
"nil": "nil", "nixpkgs": "nixpkgs",
"nix2vim": "nix2vim",
"nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs_3",
"null-ls-nvim-src": "null-ls-nvim-src",
"nur": "nur", "nur": "nur",
"nvim-lspconfig-src": "nvim-lspconfig-src",
"nvim-tree-lua-src": "nvim-tree-lua-src",
"nvim-treesitter-src": "nvim-treesitter-src",
"telescope-nvim-src": "telescope-nvim-src",
"telescope-project-nvim-src": "telescope-project-nvim-src",
"toggleterm-nvim-src": "toggleterm-nvim-src",
"wallpapers": "wallpapers", "wallpapers": "wallpapers",
"wsl": "wsl" "wsl": "wsl"
} }
}, },
"rust-overlay": {
"inputs": {
"flake-utils": [
"nil",
"flake-utils"
],
"nixpkgs": [
"nil",
"nixpkgs"
]
},
"locked": {
"lastModified": 1670552927,
"narHash": "sha256-lCE51eAGrAFS4k9W5aDGFpVtOAwQQ/rFMN80PCDh0vo=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "a0fdafd18c9cf599fde17fbaf07dbb20fa57eecb",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"telescope-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1669979094,
"narHash": "sha256-5UgCqnDs4iubnq7gER1wC8Mk9UZuo8cWqDB8ZbyGCRI=",
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"rev": "cabf991b1d3996fa6f3232327fc649bbdf676496",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"type": "github"
}
},
"telescope-project-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1665406281,
"narHash": "sha256-ZBFgUlW+h7vndazZ0lZux8i7yQHKJNDPQPZ2z96Rfpk=",
"owner": "nvim-telescope",
"repo": "telescope-project.nvim",
"rev": "ff4d3cea905383a67d1a47b9dd210c4907d858c2",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope-project.nvim",
"type": "github"
}
},
"toggleterm-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1670593071,
"narHash": "sha256-0n3WbUM3rYyR2BXgeyYuyTZIbIs5dzuIu8imsSvAc8U=",
"owner": "akinsho",
"repo": "toggleterm.nvim",
"rev": "b02a1674bd0010d7982b056fd3df4f717ff8a57a",
"type": "github"
},
"original": {
"owner": "akinsho",
"repo": "toggleterm.nvim",
"type": "github"
}
},
"utils": { "utils": {
"locked": { "locked": {
"lastModified": 1667395993, "lastModified": 1659877975,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -521,15 +164,15 @@
"wsl": { "wsl": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils_3", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_4" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1671480147, "lastModified": 1661772734,
"narHash": "sha256-IzWdZL8jMNtyKsXXJjn2L4MsBeR52WBdhciPw4latHU=", "narHash": "sha256-DkvAaLDg9D6O0i2MzUknaf/U078K4KWAZaJQmNC/tL8=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NixOS-WSL", "repo": "NixOS-WSL",
"rev": "577d7919e4380e6905e69d4a5f8f48a41ca37187", "rev": "c1b0259313f661cf74051c916cf3bb4f061ce11f",
"type": "github" "type": "github"
}, },
"original": { "original": {

128
flake.nix
View File

@ -26,75 +26,15 @@
# Community packages; used for Firefox extensions # Community packages; used for Firefox extensions
nur.url = "github:nix-community/nur"; nur.url = "github:nix-community/nur";
# Use official Firefox binary for macOS
firefox-darwin.url = "github:bandithedoge/nixpkgs-firefox-darwin";
# Wallpapers # Wallpapers
wallpapers = { wallpapers = {
url = "gitlab:exorcist365/wallpapers"; url = "gitlab:exorcist365/wallpapers";
flake = false; flake = false;
}; };
# Used to generate NixOS images for other platforms
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
# Convert Nix to Neovim config
nix2vim = {
url = "github:gytis-ivaskevicius/nix2vim";
inputs.nixpkgs.follows = "nixpkgs";
};
# Nix language server
nil.url = "github:oxalica/nil";
# Neovim plugins
nvim-lspconfig-src = {
url = "github:neovim/nvim-lspconfig";
flake = false;
};
cmp-nvim-lsp-src = {
url = "github:hrsh7th/cmp-nvim-lsp";
flake = false;
};
null-ls-nvim-src = {
url = "github:jose-elias-alvarez/null-ls.nvim";
flake = false;
};
Comment-nvim-src = {
url = "github:numToStr/Comment.nvim";
flake = false;
};
nvim-treesitter-src = {
url = "github:nvim-treesitter/nvim-treesitter";
flake = false;
};
telescope-nvim-src = {
url = "github:nvim-telescope/telescope.nvim";
flake = false;
};
telescope-project-nvim-src = {
url = "github:nvim-telescope/telescope-project.nvim";
flake = false;
};
toggleterm-nvim-src = {
url = "github:akinsho/toggleterm.nvim";
flake = false;
};
bufferline-nvim-src = {
url = "github:akinsho/bufferline.nvim";
flake = false;
};
nvim-tree-lua-src = {
url = "github:kyazdani42/nvim-tree.lua";
flake = false;
};
}; };
outputs = { self, nixpkgs, ... }@inputs: outputs = { self, nixpkgs, darwin, wsl, home-manager, nur, wallpapers }:
let let
@ -104,17 +44,10 @@
fullName = "Noah Masur"; fullName = "Noah Masur";
gitName = fullName; gitName = fullName;
gitEmail = "7386960+nmasur@users.noreply.github.com"; gitEmail = "7386960+nmasur@users.noreply.github.com";
mail.server = "noahmasur.com"; mailServer = "noahmasur.com";
dotfilesRepo = "git@github.com:nmasur/dotfiles"; dotfilesRepo = "https://github.com/nmasur/dotfiles";
}; };
# Common overlays to always use
overlays = [
inputs.nur.overlay
inputs.nix2vim.overlay
(import ./modules/neovim/plugins-overlay.nix inputs)
];
# System types to support. # System types to support.
supportedSystems = supportedSystems =
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
@ -122,50 +55,36 @@
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in rec { in {
nixosConfigurations = { nixosConfigurations = {
desktop = import ./hosts/desktop { inherit inputs globals overlays; }; desktop = import ./hosts/desktop {
wsl = import ./hosts/wsl { inherit inputs globals overlays; }; inherit nixpkgs home-manager nur globals wallpapers;
oracle = import ./hosts/oracle { inherit inputs globals overlays; }; };
wsl = import ./hosts/wsl { inherit nixpkgs wsl home-manager globals; };
}; };
darwinConfigurations = { darwinConfigurations = {
macbook = import ./hosts/macbook { inherit inputs globals overlays; }; macbook = import ./hosts/macbook {
}; inherit nixpkgs darwin home-manager nur globals;
# For quickly applying local settings with:
# home-manager switch --flake .#desktop
homeConfigurations = {
desktop =
nixosConfigurations.desktop.config.home-manager.users.${globals.user}.home;
macbook =
darwinConfigurations.macbook.config.home-manager.users."Noah.Masur".home;
};
# Package servers into images with a generator
packages = forAllSystems (system: {
aws = {
"${system}" =
import ./hosts/aws { inherit inputs globals system overlays; };
}; };
};
neovim = let pkgs = import nixpkgs { inherit system overlays; };
in import ./modules/neovim/package {
inherit pkgs;
colors =
import ./colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; };
};
});
apps = forAllSystems (system: apps = forAllSystems (system:
let pkgs = import nixpkgs { inherit system overlays; }; let pkgs = import nixpkgs { inherit system; };
in import ./apps { inherit pkgs; }); in rec {
default = readme;
# Format and install from nothing
installer = import ./apps/installer.nix { inherit pkgs; };
# Display the readme for this repository
readme = import ./apps/readme.nix { inherit pkgs; };
});
devShells = forAllSystems (system: devShells = forAllSystems (system:
let pkgs = import nixpkgs { inherit system overlays; }; let pkgs = import nixpkgs { inherit system; };
in { in {
# Used to run commands and edit files in this repo # Used to run commands and edit files in this repo
@ -182,7 +101,6 @@
vault vault
awscli2 awscli2
google-cloud-sdk google-cloud-sdk
ansible
kubectl kubectl
kubernetes-helm kubernetes-helm
kustomize kustomize

View File

@ -1,32 +0,0 @@
{ inputs, globals, ... }:
with inputs;
nixos-generators.nixosGenerate {
inherit system;
format = "amazon";
modules = [
home-manager.nixosModules.home-manager
{
user = globals.user;
fullName = globals.fullName;
dotfilesRepo = globals.dotfilesRepo;
gitName = globals.gitName;
gitEmail = globals.gitEmail;
networking.hostName = "sheep";
gui.enable = false;
colorscheme = (import ../modules/colorscheme/gruvbox);
passwordHash = null;
publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s";
# AWS settings require this
permitRootLogin = "prohibit-password";
}
../../hosts/common.nix
../../modules/nixos
../../modules/services/sshd.nix
] ++ [
# Required to fix diskSize errors during build
({ ... }: { amazonImage.sizeMB = 16 * 1024; })
];
}

View File

@ -1,80 +0,0 @@
locals {
image_file = one(fileset(path.root, "result/nixos-amazon-image-*.vhd"))
}
# Upload to S3
resource "aws_s3_object" "image" {
bucket = "your_bucket_name"
key = basename(local.image_file)
source = local.image_file
etag = filemd5(local.image_file)
}
# Setup IAM access for the VM Importer
data "aws_iam_policy_document" "vmimport_trust_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["vmie.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "vmimport" {
statement {
actions = [
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
]
resources = [
"arn:aws:s3:::${aws_s3_object.image.bucket}",
"arn:aws:s3:::${aws_s3_object.image.bucket}/*",
]
}
statement {
actions = [
"ec2:ModifySnapshotAttribute",
"ec2:CopySnapshot",
"ec2:RegisterImage",
"ec2:Describe*",
]
resources = ["*"]
}
}
resource "aws_iam_role" "vmimport" {
name = "vmimport"
assume_role_policy = data.aws_iam_policy_document.vmimport_trust_policy.json
inline_policy {
name = "vmimport"
policy = data.aws_iam_policy_document.vmimport.json
}
}
# Import to EBS
resource "aws_ebs_snapshot_import" "image" {
disk_container {
format = "VHD"
user_bucket {
s3_bucket = aws_s3_object.image.bucket
s3_key = aws_s3_object.image.key
}
}
role_name = aws_iam_role.vmimport.name
}
# Convert to AMI
resource "aws_ami" "image" {
description = "Created with NixOS."
name = replace(basename(local.image_file), "/\\.vhd$/", "")
virtualization_type = "hvm"
ebs_block_device {
device_name = "/dev/xvda"
snapshot_id = aws_ebs_snapshot_import.image.id
volume_size = 8
}
}

View File

@ -1,260 +0,0 @@
name: 'Terraform'
env:
AWS_ACCOUNT_NUMBER: ''
AWS_PLAN_ROLE_NAME: github_actions_plan
AWS_APPLY_ROLE_NAME: github_actions_admin
# Always required. Used for authenticating to AWS, but can also act as your
# default region if you don't want to specify in the provider configuration.
AWS_REGION: us-east-1
# You must change these to fit your project.
TF_VAR_project: change-me
TF_VAR_label: change-me
TF_VAR_owner: Your Name Here
# If storing Terraform in a subdirectory, specify it here.
TERRAFORM_DIRECTORY: .
# Pinned versions of tools to use.
# Check for new releases:
# - https://github.com/hashicorp/terraform/releases
# - https://github.com/fugue/regula/releases
# - https://github.com/terraform-linters/tflint/releases
TERRAFORM_VERSION: 1.2.6
REGULA_VERSION: 2.9.0
TFLINT_VERSION: 0.39.1
# Terraform configuration options
TERRAFORM_PARALLELISM: 10
# These variables are passed to Terraform based on GitHub information.
TF_VAR_repo: ${{ github.repository }}
# This workflow is triggered in the following ways.
on:
# Any push or merge to these branches.
push:
branches:
- dev
- prod
# Any pull request targeting these branches (plan only).
pull_request:
branches:
- dev
- prod
# Any manual trigger on these branches.
workflow_dispatch:
branches:
- dev
- prod
# -------------------------------------------------------------------
# The rest of this workflow can operate without adjustments. Edit the
# below content at your own risk!
# -------------------------------------------------------------------
# Used to connect to AWS IAM
permissions:
id-token: write
contents: read
pull-requests: write
# Only run one workflow at a time for each Terraform state. This prevents
# lockfile conflicts, especially during PR vs push.
concurrency: terraform-${{ github.base_ref || github.ref }}
jobs:
terraform:
name: 'Terraform'
# Change this if you need to run your deployment on-prem.
runs-on: ubuntu-latest
steps:
# Downloads the current repo code to the runner.
- name: Checkout Repo Code
uses: actions/checkout@v2
# Install Nix
- name: Install Nix
uses: cachix/install-nix-action@v17
# Build the image
- name: Build Image
run: nix build .#aws
# Login to AWS
- name: AWS Assume Role
uses: aws-actions/configure-aws-credentials@v1.6.1
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
# Exports all GitHub Secrets as environment variables prefixed by
# "TF_VAR_", which exposes them to Terraform. The name of each GitHub
# Secret must match its Terraform variable name exactly.
- name: Export Secrets to Terraform Variables
env:
ALL_SECRETS: ${{ toJson(secrets) }}
run: |
echo "$ALL_SECRETS" \
| jq "to_entries | .[] | \"TF_VAR_\" + ( .key | ascii_downcase ) + \"=\" + .value" \
| tr -d \" >> $GITHUB_ENV
# Installs the Terraform binary and some other accessory functions.
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
# Checks whether Terraform is formatted properly. If this fails, you
# should install the pre-commit hook.
- name: Check Formatting
run: |
terraform fmt -no-color -check -diff -recursive
# Downloads a Terraform code lint test.
- uses: terraform-linters/setup-tflint@v1
name: Setup TFLint
with:
tflint_version: v${{ env.TFLINT_VERSION }}
# Sets up linting with this codebase.
- name: Init TFLint
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: tflint --init
# Lints the current code.
- name: Run TFLint
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
tflint -f compact
find ./modules/* -type d -maxdepth 0 | xargs -I __ tflint -f compact --disable-rule=terraform_required_providers --disable-rule=terraform_required_version __
# Connects to remote state backend and download providers.
- name: Terraform Init
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform init \
-backend-config="role_arn=${{ env.AWS_STATE_ROLE_ARN }}" \
-backend-config="region=us-east-1" \
-backend-config="workspace_key_prefix=accounts/${{ env.AWS_ACCOUNT_NUMBER }}/${{ github.repository }}" \
-backend-config="key=state.tfstate" \
-backend-config="dynamodb_table=global-tf-state-lock"
# Set the Terraform Workspace to the current branch name.
- name: Set Terraform Workspace
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
shell: bash
run: |
export WORKSPACE=${{ github.base_ref || github.ref_name }}
terraform workspace select ${WORKSPACE} || terraform workspace new $WORKSPACE
echo "TF_WORKSPACE=$(echo ${WORKSPACE} | sed 's/\//_/g')" >> $GITHUB_ENV
# Checks differences between current code and infrastructure state.
- name: Terraform Plan
id: plan
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform plan \
-input=false \
-no-color \
-out=tfplan \
-parallelism=${TERRAFORM_PARALLELISM} \
-var-file=variables-${TF_WORKSPACE}.tfvars
# Gets the results of the plan for pull requests.
- name: Terraform Show Plan
id: show
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: terraform show -no-color tfplan
# Adds the results of the plan to the pull request.
- name: Comment Plan
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
env:
STDOUT: "```terraform\n${{ steps.show.outputs.stdout }}```"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// 1. Retrieve existing bot comments for the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Terraform Format and Style')
})
// 2. Prepare format of the comment
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
<details><summary>Validation Output</summary>
\`\`\`\n
${{ steps.validate.outputs.stdout }}
\`\`\`
</details>
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`;
// 3. If we have a comment, update it, otherwise create a new one
if (botComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: output
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}
# Downloads Regula and checks whether the plan meets compliance requirements.
- name: Regula Compliance Check
shell: bash
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
REGULA_URL="https://github.com/fugue/regula/releases/download/v${REGULA_VERSION}/regula_${REGULA_VERSION}_Linux_x86_64.tar.gz"
curl -sL "$REGULA_URL" -o regula.tar.gz
tar xzf regula.tar.gz
terraform show -json tfplan | ./regula run
# Deploys infrastructure or changes to infrastructure.
- name: Terraform Apply
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform apply \
-auto-approve \
-input=false \
-parallelism=${TERRAFORM_PARALLELISM} \
tfplan

View File

@ -1,24 +1,11 @@
{ config, lib, pkgs, ... }: { { config, lib, pkgs, ... }: {
imports = [ imports =
./applications [ ../modules/shell ../modules/neovim ../modules/repositories/dotfiles.nix ];
./darwin
./gaming
./graphical
./hardware
./mail
./neovim
./nixos
./programming
./repositories
./services
./shell
./wsl
];
options = { options = with lib; {
user = lib.mkOption { user = mkOption {
type = lib.types.str; type = types.str;
description = "Primary user of the system"; description = "Primary user of the system";
}; };
fullName = lib.mkOption { fullName = lib.mkOption {
@ -34,67 +21,45 @@
if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads"; if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads";
}; };
}; };
identityFile = lib.mkOption {
type = lib.types.str;
description = "Path to existing private key file.";
default = "/etc/ssh/ssh_host_ed25519_key";
};
gui = { gui = {
enable = lib.mkEnableOption { enable = mkEnableOption {
description = "Enable graphics."; description = "Enable graphics";
default = false; default = false;
}; };
}; };
theme = { colorscheme = mkOption {
colors = lib.mkOption { type = types.attrs;
type = lib.types.attrs; description = "Base16 color scheme";
description = "Base16 color scheme.";
default = (import ../colorscheme/gruvbox).dark;
};
dark = lib.mkOption {
type = lib.types.bool;
description = "Enable dark mode.";
default = true;
};
}; };
homePath = mkOption {
# colorscheme = lib.mkOption { type = types.path;
# type = types.attrs;
# description = "Base16 color scheme";
# };
homePath = lib.mkOption {
type = lib.types.path;
description = "Path of user's home directory."; description = "Path of user's home directory.";
default = builtins.toPath (if pkgs.stdenv.isDarwin then default = builtins.toPath (if pkgs.stdenv.isDarwin then
"/Users/${config.user}" "/Users/${config.user}"
else else
"/home/${config.user}"); "/home/${config.user}");
}; };
dotfilesPath = mkOption {
dotfilesPath = lib.mkOption { type = types.path;
type = lib.types.path;
description = "Path of dotfiles repository."; description = "Path of dotfiles repository.";
default = config.homePath + "/dev/personal/dotfiles"; default = config.homePath + "/dev/personal/dotfiles";
}; };
dotfilesRepo = lib.mkOption { dotfilesRepo = mkOption {
type = lib.types.str; type = types.str;
description = "Link to dotfiles repository."; description = "Link to dotfiles repository.";
}; };
unfreePackages = lib.mkOption { unfreePackages = mkOption {
type = lib.types.listOf lib.types.str; type = types.listOf types.str;
description = "List of unfree packages to allow."; description = "List of unfree packages to allow.";
default = [ ]; default = [ ];
}; };
}; };
config = let stateVersion = "23.05"; config = let stateVersion = "22.11";
in { in {
# Enable features in Nix commands # Enable features in Nix commands
nix.extraOptions = '' nix.extraOptions = "experimental-features = nix-command flakes";
experimental-features = nix-command flakes
warn-dirty = false
'';
# Basic common system packages for all devices # Basic common system packages for all devices
environment.systemPackages = with pkgs; [ git vim wget curl ]; environment.systemPackages = with pkgs; [ git vim wget curl ];

View File

@ -1,6 +1,4 @@
{ inputs, globals, ... }: { nixpkgs, home-manager, nur, globals, wallpapers, ... }:
with inputs;
# System configuration for my desktop # System configuration for my desktop
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
@ -10,40 +8,37 @@ nixpkgs.lib.nixosSystem {
globals globals
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
physical = true;
networking.hostName = "desktop"; networking.hostName = "desktop";
nixpkgs.overlays = [ nur.overlay ]; nixpkgs.overlays = [ nur.overlay ];
# Set registry to flake packages, used for nix X commands # Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs; nix.registry.nixpkgs.flake = nixpkgs;
identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gaming.steam = true;
gui.enable = true; gaming.leagueoflegends = true;
theme = { gaming.legendary = true;
colors = (import ../../colorscheme/gruvbox).dark; gui = {
dark = true; enable = true;
compositor.enable = true;
wallpaper = "${wallpapers}/gruvbox/road.jpg";
gtk.theme = { name = "Adwaita-dark"; };
}; };
wallpaper = "${wallpapers}/gruvbox/road.jpg"; colorscheme = (import ../../modules/colorscheme/gruvbox);
gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark"; passwordHash =
passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF.";
media.enable = true;
firefox.enable = true;
kitty.enable = true;
"1password".enable = true;
discord.enable = true;
nautilus.enable = true;
obsidian.enable = true;
mail.aerc.enable = true;
mail.himalaya.enable = true;
gaming.enable = true;
gaming.steam.enable = true;
gaming.legendary.enable = true;
keybase.enable = true;
mullvad.enable = true;
nixlang.enable = true;
dotfiles.enable = true;
} }
./hardware-configuration.nix ./hardware-configuration.nix
../../modules ../common.nix
../../modules/hardware
../../modules/nixos
../../modules/graphical
../../modules/gaming
../../modules/applications
../../modules/mail/himalaya.nix
../../modules/repositories/notes.nix
../../modules/services/keybase.nix
../../modules/services/gnupg.nix
../../modules/services/mullvad.nix
../../modules/programming/nix.nix
../../modules/programming/haskell.nix
]; ];
} }

View File

@ -1,13 +1,10 @@
{ inputs, globals, overlays, ... }: { nixpkgs, darwin, home-manager, nur, globals, ... }:
with inputs;
# System configuration for my work MacBook # System configuration for my work MacBook
darwin.lib.darwinSystem { darwin.lib.darwinSystem {
system = "x86_64-darwin"; system = "x86_64-darwin";
specialArgs = { }; specialArgs = { };
modules = [ modules = [
../../modules
(globals // { (globals // {
user = "Noah.Masur"; user = "Noah.Masur";
gitName = "Noah-Masur_1701"; gitName = "Noah-Masur_1701";
@ -15,30 +12,23 @@ darwin.lib.darwinSystem {
}) })
home-manager.darwinModules.home-manager home-manager.darwinModules.home-manager
{ {
networking.hostName = "noah-masur-mac";
identityFile = "/Users/Noah.Masur/.ssh/id_ed25519";
gui.enable = true; gui.enable = true;
theme = { colorscheme = (import ../../modules/colorscheme/gruvbox);
colors = (import ../../colorscheme/gruvbox).dark; mailUser = globals.user;
dark = true; nixpkgs.overlays = [ nur.overlay ];
};
mail.user = globals.user;
nixpkgs.overlays = [ firefox-darwin.overlay ] ++ overlays;
# Set registry to flake packages, used for nix X commands # Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs; nix.registry.nixpkgs.flake = nixpkgs;
mail.aerc.enable = true;
mail.himalaya.enable = true;
kitty.enable = true;
discord.enable = true;
firefox.enable = true;
dotfiles.enable = true;
nixlang.enable = true;
terraform.enable = true;
python.enable = true;
lua.enable = true;
kubernetes.enable = true;
"1password".enable = true;
} }
../common.nix
../../modules/darwin
../../modules/applications/alacritty.nix
../../modules/applications/discord.nix
../../modules/mail/himalaya.nix
../../modules/repositories/notes.nix
../../modules/programming/nix.nix
../../modules/programming/terraform.nix
../../modules/programming/python.nix
../../modules/programming/lua.nix
../../modules/programming/kubernetes.nix
]; ];
} }

View File

@ -1,90 +0,0 @@
{ inputs, globals, overlays, ... }:
with inputs;
# System configuration for an Oracle free server
# How to install:
# https://blog.korfuri.fr/posts/2022/08/nixos-on-an-oracle-free-tier-ampere-machine/
nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
specialArgs = { };
modules = [
./hardware-configuration.nix
../../modules
(removeAttrs globals [ "mail.server" ])
home-manager.nixosModules.home-manager
{
server = true;
gui.enable = false;
theme = { colors = (import ../../colorscheme/gruvbox).dark; };
nixpkgs.overlays = overlays;
# FQDNs for various services
networking.hostName = "oracle";
bookServer = "books.masu.rs";
streamServer = "stream.masu.rs";
nextcloudServer = "cloud.masu.rs";
transmissionServer = "download.masu.rs";
metricsServer = "metrics.masu.rs";
vaultwardenServer = "vault.masu.rs";
giteaServer = "git.masu.rs";
# Disable passwords, only use SSH key
publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s";
# Nextcloud backup config
backup.s3 = {
endpoint = "s3.us-west-002.backblazeb2.com";
bucket = "noahmasur-backup";
accessKeyId = "0026b0e73b2e2c80000000005";
};
# Grant access to Jellyfin directories from Nextcloud
users.users.nextcloud.extraGroups = [ "jellyfin" ];
# Wireguard config for Transmission
networking.wireguard.interfaces.wg0 = {
# The local IPs for this machine within the Wireguard network
# Any inbound traffic bound for these IPs should be kept on localhost
ips = [ "10.66.13.200/32" "fc00:bbbb:bbbb:bb01::3:dc7/128" ];
peers = [{
# Identity of Wireguard target peer (VPN)
publicKey = "bOOP5lIjqCdDx5t+mP/kEcSbHS4cZqE0rMlBI178lyY=";
# The public internet address of the target peer
endpoint = "86.106.143.132:51820";
# Which outgoing IP ranges should be sent through Wireguard
allowedIPs = [ "0.0.0.0/0" "::0/0" ];
# Send heartbeat signal within the network
persistentKeepalive = 25;
}];
};
# VPN port forwarding
services.transmission.settings.peer-port = 57599;
# Grant access to Transmission directories from Jellyfin
users.users.jellyfin.extraGroups = [ "transmission" ];
# Proxy traffic with Cloudflare
cloudflare.enable = true;
# Setup Minecraft server
gaming.minecraft-server.enable = true;
# Clone dotfiles
dotfiles.enable = true;
}
];
}

View File

@ -1,34 +0,0 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_pci" "usbhid" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/e1b6bd50-306d-429a-9f45-78f57bc597c3";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/D5CA-237A";
fsType = "vfat";
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.eth0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
}

View File

@ -1,4 +0,0 @@
# Scan hosts: ssh-keyscan -t ed25519 <hostnames>
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s noah
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHVknmPi7sG6ES0G0jcsvebzKGWWaMfJTYgvOue6EULI oracle.masu.rs

20
hosts/server/default.nix Normal file
View File

@ -0,0 +1,20 @@
{ nixpkgs, home-manager, globals, ... }:
# System configuration for a generic server
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { };
modules = [
globals
home-manager.nixosModules.home-manager
{
networking.hostName = "sheep";
gui.enable = false;
colorscheme = (import ../../modules/colorscheme/gruvbox);
passwordHash =
"$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF.";
}
../common.nix
../../modules/nixos
];
}

View File

@ -1,6 +1,4 @@
{ inputs, globals, ... }: { nixpkgs, wsl, home-manager, globals, ... }:
with inputs;
# System configuration for WSL # System configuration for WSL
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
@ -10,18 +8,14 @@ nixpkgs.lib.nixosSystem {
globals globals
wsl.nixosModules.wsl wsl.nixosModules.wsl
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
../../modules
{ {
networking.hostName = "wsl"; networking.hostName = "wsl";
# Set registry to flake packages, used for nix X commands # Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs; nix.registry.nixpkgs.flake = nixpkgs;
identityFile = "/home/${globals.user}/.ssh/id_ed25519";
gui.enable = false; gui.enable = false;
theme = { colorscheme = (import ../../modules/colorscheme/gruvbox);
colors = (import ../../colorscheme/gruvbox).dark; passwordHash =
dark = true; "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF.";
};
passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512;
wsl = { wsl = {
enable = true; enable = true;
automountPath = "/mnt"; automountPath = "/mnt";
@ -31,12 +25,13 @@ nixpkgs.lib.nixosSystem {
interop.includePath = interop.includePath =
false; # Including Windows PATH will slow down Neovim command mode false; # Including Windows PATH will slow down Neovim command mode
}; };
mail.aerc.enable = true;
mail.himalaya.enable = true;
dotfiles.enable = true;
nixlang.enable = true;
lua.enable = true;
} }
../common.nix
../../modules/wsl
../../modules/nixos
../../modules/mail/himalaya.nix
../../modules/repositories/notes.nix
../../modules/programming/nix.nix
../../modules/programming/lua.nix
]; ];
} }

View File

@ -1,20 +1,10 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options = { config = lib.mkIf config.gui.enable {
"1password" = { unfreePackages = [ "1password" "_1password-gui" ];
enable = lib.mkEnableOption { home-manager.users.${config.user} = {
description = "Enable 1Password."; home.packages = with pkgs; [ _1password-gui ];
default = false;
};
}; };
}; };
config = lib.mkIf
(config.gui.enable && config."1password".enable && pkgs.stdenv.isLinux) {
unfreePackages = [ "1password" "_1password-gui" ];
home-manager.users.${config.user} = {
home.packages = with pkgs; [ _1password-gui ];
};
};
} }

View File

@ -1,15 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options = { config = lib.mkIf config.gui.enable {
alacritty = {
enable = lib.mkEnableOption {
description = "Enable Alacritty.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.alacritty.enable) {
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
xsession.windowManager.i3.config.terminal = "alacritty"; xsession.windowManager.i3.config.terminal = "alacritty";
programs.rofi.terminal = "${pkgs.alacritty}/bin/alacritty"; programs.rofi.terminal = "${pkgs.alacritty}/bin/alacritty";
@ -32,8 +23,8 @@
key_bindings = [ key_bindings = [
# Used for word completion in fish_user_key_bindings # Used for word completion in fish_user_key_bindings
{ {
key = "Return"; key = "L";
mods = "Shift"; mods = "Control|Shift";
chars = "\\x1F"; chars = "\\x1F";
} }
# Used for searching nixpkgs in fish_user_key_bindings # Used for searching nixpkgs in fish_user_key_bindings
@ -43,8 +34,8 @@
chars = "\\x11F"; chars = "\\x11F";
} }
{ {
key = "H"; key = "K";
mods = "Control|Shift"; mods = "Control";
mode = "~Vi"; mode = "~Vi";
action = "ToggleViMode"; action = "ToggleViMode";
} }
@ -63,32 +54,32 @@
]; ];
colors = { colors = {
primary = { primary = {
background = config.theme.colors.base00; background = config.colorscheme.base00;
foreground = config.theme.colors.base05; foreground = config.colorscheme.base05;
}; };
cursor = { cursor = {
text = "#1d2021"; text = "#1d2021";
cursor = config.theme.colors.base05; cursor = config.colorscheme.base05;
}; };
normal = { normal = {
black = "#1d2021"; black = "#1d2021";
red = config.theme.colors.base08; red = config.colorscheme.base08;
green = config.theme.colors.base0B; green = config.colorscheme.base0B;
yellow = config.theme.colors.base0A; yellow = config.colorscheme.base0A;
blue = config.theme.colors.base0D; blue = config.colorscheme.base0D;
magenta = config.theme.colors.base0E; magenta = config.colorscheme.base0E;
cyan = config.theme.colors.base0C; cyan = config.colorscheme.base0C;
white = config.theme.colors.base05; white = config.colorscheme.base05;
}; };
bright = { bright = {
black = config.theme.colors.base03; black = config.colorscheme.base03;
red = config.theme.colors.base09; red = config.colorscheme.base09;
green = config.theme.colors.base01; green = config.colorscheme.base01;
yellow = config.theme.colors.base02; yellow = config.colorscheme.base02;
blue = config.theme.colors.base04; blue = config.colorscheme.base04;
magenta = config.theme.colors.base06; magenta = config.colorscheme.base06;
cyan = config.theme.colors.base0F; cyan = config.colorscheme.base0F;
white = config.theme.colors.base07; white = config.colorscheme.base07;
}; };
}; };
draw_bold_text_with_bright_colors = false; draw_bold_text_with_bright_colors = false;

View File

@ -1,15 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options = { config = lib.mkIf config.gui.enable {
calibre = {
enable = lib.mkEnableOption {
description = "Enable Calibre.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.calibre.enable) {
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
home.packages = with pkgs; [ calibre ]; home.packages = with pkgs; [ calibre ];
# home.sessionVariables = { CALIBRE_USE_DARK_PALETTE = 1; }; # home.sessionVariables = { CALIBRE_USE_DARK_PALETTE = 1; };

View File

@ -6,7 +6,6 @@
./calibre.nix ./calibre.nix
./discord.nix ./discord.nix
./firefox.nix ./firefox.nix
./kitty.nix
./media.nix ./media.nix
./obsidian.nix ./obsidian.nix
./qbittorrent.nix ./qbittorrent.nix

View File

@ -1,15 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options = { config = lib.mkIf config.gui.enable {
discord = {
enable = lib.mkEnableOption {
description = "Enable Discord.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.discord.enable) {
unfreePackages = [ "discord" ]; unfreePackages = [ "discord" ];
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
home.packages = with pkgs; [ discord ]; home.packages = with pkgs; [ discord ];

View File

@ -1,68 +1,42 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
{ {
config = lib.mkIf config.gui.enable {
options = { unfreePackages = [ "onepassword-password-manager" "okta-browser-plugin" ];
firefox = {
enable = lib.mkEnableOption {
description = "Enable Firefox.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.firefox.enable) {
unfreePackages = [
(lib.mkIf config."1password".enable "onepassword-password-manager")
"okta-browser-plugin"
];
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
programs.firefox = { programs.firefox = {
enable = true; enable = true;
package =
if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox;
extensions = with pkgs.nur.repos.rycee.firefox-addons; [ extensions = with pkgs.nur.repos.rycee.firefox-addons; [
ublock-origin ublock-origin
vimium vimium
multi-account-containers multi-account-containers
facebook-container facebook-container
temporary-containers temporary-containers
(lib.mkIf config."1password".enable onepassword-password-manager) onepassword-password-manager
okta-browser-plugin okta-browser-plugin
sponsorblock sponsorblock
reddit-enhancement-suite reddit-enhancement-suite
return-youtube-dislikes
bypass-paywalls-clean bypass-paywalls-clean
markdownload markdownload
darkreader darkreader
snowflake snowflake
don-t-fuck-with-paste don-t-fuck-with-paste
i-dont-care-about-cookies i-dont-care-about-cookies
wappalyzer
]; ];
profiles.default = { profiles.Profile0 = {
id = 0; id = 0;
name = "default"; name = "default";
isDefault = true; isDefault = true;
settings = { settings = {
"app.update.auto" = false;
"browser.aboutConfig.showWarning" = false; "browser.aboutConfig.showWarning" = false;
"browser.warnOnQuit" = false; "browser.warnOnQuit" = false;
"browser.quitShortcut.disabled" =
if pkgs.stdenv.isLinux then true else false;
"browser.theme.dark-private-windows" = true; "browser.theme.dark-private-windows" = true;
"browser.toolbars.bookmarks.visibility" = "newtab"; "browser.toolbars.bookmarks.visibility" = "newtab";
"browser.startup.page" = 3; # Restore previous session "browser.startup.page" = 3; # Restore previous session
"browser.newtabpage.enabled" = false; # Make new tabs blank "browser.newtabpage.enabled" = false; # Make new tabs blank
"trailhead.firstrun.didSeeAboutWelcome" =
true; # Disable welcome splash
"dom.forms.autocomplete.formautofill" = false; # Disable autofill
"extensions.formautofill.creditCards.enabled" =
false; # Disable credit cards
"dom.payments.defaults.saveAddress" = false; # Disable address save
"general.autoScroll" = true; # Drag middle-mouse to scroll "general.autoScroll" = true; # Drag middle-mouse to scroll
"services.sync.prefs.sync.general.autoScroll" = "services.sync.prefs.sync.general.autoScroll" =
false; # Prevent disabling autoscroll false; # Prevent disabling autoscroll
@ -70,86 +44,68 @@
"toolkit.legacyUserProfileCustomizations.stylesheets" = "toolkit.legacyUserProfileCustomizations.stylesheets" =
true; # Allow userChrome.css true; # Allow userChrome.css
"layout.css.color-mix.enabled" = true; "layout.css.color-mix.enabled" = true;
"ui.systemUsesDarkTheme" =
if config.theme.dark == true then 1 else 0;
}; };
userChrome = '' userChrome = ''
:root { :root {
--focus-outline-color: ${config.theme.colors.base04} !important; --focus-outline-color: ${config.colorscheme.base04} !important;
--toolbar-color: ${config.theme.colors.base07} !important; --toolbar-color: ${config.colorscheme.base07} !important;
--tab-min-height: 30px !important; --tab-min-height: 30px !important;
} }
/* Background of tab bar */ /* Background of tab bar */
.toolbar-items { .toolbar-items {
background-color: ${config.theme.colors.base00} !important; background-color: ${config.colorscheme.base00} !important;
}
/* Extra tab bar sides on macOS */
.titlebar-spacer {
background-color: ${config.theme.colors.base00} !important;
}
.titlebar-buttonbox-container {
background-color: ${config.theme.colors.base00} !important;
}
#tabbrowser-tabs {
border-inline-start: 0 !important;
}
/* Private Browsing indicator on macOS */
#private-browsing-indicator-with-label {
background-color: ${config.theme.colors.base00} !important;
margin-inline: 0 !important;
padding-inline: 7px;
} }
/* Tabs themselves */ /* Tabs themselves */
.tabbrowser-tab .tab-stack { .tabbrowser-tab .tab-stack {
border-radius: 5px 5px 0 0; border-radius: 5px 5px 0 0;
overflow: hidden; overflow: hidden;
background-color: ${config.theme.colors.base00}; background-color: ${config.colorscheme.base00};
color: ${config.theme.colors.base06} !important; color: ${config.colorscheme.base06} !important;
} }
.tab-content { .tab-content {
border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 40%, transparent); border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 40%, transparent);
border-radius: 5px 5px 0 0; border-radius: 5px 5px 0 0;
background-color: ${config.theme.colors.base00}; background-color: ${config.colorscheme.base00};
color: ${config.theme.colors.base06} !important; color: ${config.colorscheme.base06} !important;
} }
.tab-content[selected=true] { .tab-content[selected=true] {
border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 25%, transparent); border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 25%, transparent);
background-color: ${config.theme.colors.base01} !important; background-color: ${config.colorscheme.base01} !important;
color: ${config.theme.colors.base07} !important; color: ${config.colorscheme.base07} !important;
} }
/* Below tab bar */ /* Below tab bar */
#nav-bar { #nav-bar {
background: ${config.theme.colors.base01} !important; background: ${config.colorscheme.base01} !important;
} }
/* URL bar in nav bar */ /* URL bar in nav bar */
#urlbar[focused=true] { #urlbar[focused=true] {
color: ${config.theme.colors.base07} !important; color: ${config.colorscheme.base07} !important;
background: ${config.theme.colors.base02} !important; background: ${config.colorscheme.base02} !important;
caret-color: ${config.theme.colors.base05} !important; caret-color: ${config.colorscheme.base05} !important;
} }
#urlbar:not([focused=true]) { #urlbar:not([focused=true]) {
color: ${config.theme.colors.base04} !important; color: ${config.colorscheme.base04} !important;
background: ${config.theme.colors.base02} !important; background: ${config.colorscheme.base02} !important;
} }
#urlbar ::-moz-selection { #urlbar ::-moz-selection {
color: ${config.theme.colors.base07} !important; color: ${config.colorscheme.base07} !important;
background: ${config.theme.colors.base02} !important; background: ${config.colorscheme.base02} !important;
} }
#urlbar-input-container { #urlbar-input-container {
border: 1px solid ${config.theme.colors.base01} !important; border: 1px solid ${config.colorscheme.base01} !important;
} }
#urlbar-background { #urlbar-background {
background: ${config.theme.colors.base01} !important; background: ${config.colorscheme.base01} !important;
} }
/* Text in URL bar */ /* Text in URL bar */
#urlbar-input, #urlbar-scheme, .searchbar-textbox { #urlbar-input, #urlbar-scheme, .searchbar-textbox {
color: ${config.theme.colors.base07} !important; color: ${config.colorscheme.base07} !important;
} }
''; '';
userContent = '' userContent = ''
@-moz-document url-prefix(about:blank) { @-moz-document url-prefix(about:blank) {
* { * {
background-color:${config.theme.colors.base01} !important; background-color:${config.colorscheme.base01} !important;
} }
} }
''; '';

View File

@ -1,88 +0,0 @@
{ config, pkgs, lib, ... }: {
options = {
kitty = {
enable = lib.mkEnableOption {
description = "Enable Kitty.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.kitty.enable) {
home-manager.users.${config.user} = {
# xsession.windowManager.i3.config.terminal = "kitty";
# programs.rofi.terminal = "${pkgs.kitty}/bin/kitty";
programs.kitty = {
enable = true;
environment = { };
extraConfig = "";
font.size = 14;
keybindings = {
"shift+enter" = "send_text all \\x1F";
"super+f" = "toggle_fullscreen";
};
settings = {
# Colors (adapted from: https://github.com/kdrag0n/base16-kitty/blob/master/templates/default-256.mustache)
background = config.theme.colors.base00;
foreground = config.theme.colors.base05;
selection_background = config.theme.colors.base05;
selection_foreground = config.theme.colors.base00;
url_color = config.theme.colors.base04;
cursor = config.theme.colors.base05;
active_border_color = config.theme.colors.base03;
inactive_border_color = config.theme.colors.base01;
active_tab_background = config.theme.colors.base00;
active_tab_foreground = config.theme.colors.base05;
inactive_tab_background = config.theme.colors.base01;
inactive_tab_foreground = config.theme.colors.base04;
tab_bar_background = config.theme.colors.base01;
# normal
color0 = config.theme.colors.base00;
color1 = config.theme.colors.base08;
color2 = config.theme.colors.base0B;
color3 = config.theme.colors.base0A;
color4 = config.theme.colors.base0D;
color5 = config.theme.colors.base0E;
color6 = config.theme.colors.base0C;
color7 = config.theme.colors.base05;
# bright
color8 = config.theme.colors.base03;
color9 = config.theme.colors.base08;
color10 = config.theme.colors.base0B;
color11 = config.theme.colors.base0A;
color12 = config.theme.colors.base0D;
color13 = config.theme.colors.base0E;
color14 = config.theme.colors.base0C;
color15 = config.theme.colors.base07;
# extended base16 colors
color16 = config.theme.colors.base09;
color17 = config.theme.colors.base0F;
color18 = config.theme.colors.base01;
color19 = config.theme.colors.base02;
color20 = config.theme.colors.base04;
color21 = config.theme.colors.base06;
# Scrollback
scrolling_lines = 10000;
scrollback_pager_history_size = 10; # MB
scrollback_pager = ''
${pkgs.neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -'';
# Window
window_padding_width = 6;
tab_bar_edge = "top";
tab_bar_style = "slant";
# Audio
enable_audio_bell = false;
};
};
};
};
}

View File

@ -1,20 +1,10 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options = { config = lib.mkIf config.gui.enable {
media = {
enable = lib.mkEnableOption {
description = "Enable media programs.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.media.enable) {
home-manager.users.${config.user}.home.packages = with pkgs; [ home-manager.users.${config.user}.home.packages = with pkgs; [
mpv # Video viewer mpv # Video viewer
sxiv # Image viewer sxiv # Image viewer
mupdf # PDF viewer mupdf # PDF viewer
zathura # PDF viewer
]; ];
}; };

View File

@ -1,28 +1,12 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options = {
nautilus = {
enable = lib.mkEnableOption {
description = "Enable Nautilus file manager.";
default = false;
};
};
};
# Install Nautilus file manager # Install Nautilus file manager
config = lib.mkIf (config.gui.enable && config.nautilus.enable) { config = lib.mkIf config.gui.enable {
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
home.packages = with pkgs; [ home.packages = with pkgs; [
gnome.nautilus gnome.nautilus
gnome.sushi # Quick preview with spacebar gnome.sushi # Quick preview with spacebar
]; ];
programs.fish.functions = {
qr = {
body =
"${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | ${pkgs.gnome.sushi}/bin/sushi /tmp/qr.png";
};
};
}; };
}; };

View File

@ -1,15 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options = { config = lib.mkIf config.gui.enable {
obsidian = {
enable = lib.mkEnableOption {
description = "Enable Obsidian.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.obsidian.enable) {
unfreePackages = [ "obsidian" ]; unfreePackages = [ "obsidian" ];
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
home.packages = with pkgs; [ obsidian ]; home.packages = with pkgs; [ obsidian ];

View File

@ -1,15 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options = { config = lib.mkIf config.gui.enable {
qbittorrent = {
enable = lib.mkEnableOption {
description = "Enable qBittorrent.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.qbittorrent.enable) {
home-manager.users.${config.user} = { home-manager.users.${config.user} = {

View File

@ -0,0 +1,22 @@
{
name = "gruvbox"; # Dark, Medium
author =
"Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)";
base00 = "#282828"; # ----
base01 = "#3c3836"; # ---
base02 = "#504945"; # --
base03 = "#665c54"; # -
base04 = "#bdae93"; # +
base05 = "#d5c4a1"; # ++
base06 = "#ebdbb2"; # +++
base07 = "#fbf1c7"; # ++++
base08 = "#fb4934"; # red
base09 = "#fe8019"; # orange
base0A = "#fabd2f"; # yellow
base0B = "#b8bb26"; # green
base0C = "#8ec07c"; # aqua/cyan
base0D = "#83a598"; # blue
base0E = "#d3869b"; # purple
base0F = "#d65d0e"; # brown
neovimConfig = ./neovim.lua;
}

View File

@ -0,0 +1,13 @@
local M = {}
M.packer = function(use)
use({
"lifepillar/vim-gruvbox8",
config = function()
vim.g.gruvbox_italicize_strings = 0
vim.cmd("colorscheme gruvbox8")
end,
})
end
return M

View File

@ -1,7 +1,7 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
# MacOS-specific settings for Alacritty # MacOS-specific settings for Alacritty
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { home-manager.users.${config.user} = {
programs.alacritty.settings = { programs.alacritty.settings = {
font.size = lib.mkForce 20.0; font.size = lib.mkForce 20.0;
shell.program = "${pkgs.fish}/bin/fish"; shell.program = "${pkgs.fish}/bin/fish";

View File

@ -5,9 +5,8 @@
./fonts.nix ./fonts.nix
./hammerspoon.nix ./hammerspoon.nix
./homebrew.nix ./homebrew.nix
./kitty.nix
./networking.nix
./nixpkgs.nix ./nixpkgs.nix
./ssl.nix
./system.nix ./system.nix
./tmux.nix ./tmux.nix
./user.nix ./user.nix

View File

@ -1,15 +1,12 @@
{ config, pkgs, lib, ... }: { { config, pkgs, ... }: {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { home-manager.users.${config.user} = {
home.packages = with pkgs; home.packages = with pkgs;
[ (nerdfonts.override { fonts = [ "VictorMono" ]; }) ]; [ (nerdfonts.override { fonts = [ "FiraCode" ]; }) ];
programs.alacritty.settings = { font.normal.family = "VictorMono"; }; programs.alacritty.settings = {
font.normal.family = "FiraCode Nerd Font Mono";
programs.kitty.font = {
package = (pkgs.nerdfonts.override { fonts = [ "VictorMono" ]; });
name = "VictorMono Nerd Font Mono";
}; };
}; };

View File

@ -1,32 +1,15 @@
{ config, pkgs, lib, ... }: { { config, ... }: {
# Hammerspoon - MacOS custom automation scripting # Hammerspoon - MacOS custom automation scripting
config = lib.mkIf pkgs.stdenv.isDarwin { home-manager.users.${config.user} = {
xdg.configFile.hammerspoon = { source = ./hammerspoon; };
home-manager.users.${config.user} = {
xdg.configFile."hammerspoon/init.lua".source = ./hammerspoon/init.lua;
xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source =
./hammerspoon/Spoons/ControlEscape.spoon;
xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source =
./hammerspoon/Spoons/DismissAlerts.spoon;
xdg.configFile."hammerspoon/Spoons/Launcher.spoon/init.lua".source =
pkgs.substituteAll {
src = ./hammerspoon/Spoons/Launcher.spoon/init.lua;
firefox = "${pkgs.firefox-bin}/Applications/Firefox.app";
discord = "${pkgs.discord}/Applications/Discord.app";
kitty = "${pkgs.kitty}/Applications/kitty.app";
};
xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source =
./hammerspoon/Spoons/MoveWindow.spoon;
};
homebrew.casks = [ "hammerspoon" ];
system.activationScripts.postUserActivation.text = ''
defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua"
'';
}; };
homebrew.casks = [ "hammerspoon" ];
system.activationScripts.postUserActivation.text = ''
defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua"
'';
} }

View File

@ -69,7 +69,7 @@ function obj:init()
-- If any other key is pressed, don't send escape -- If any other key is pressed, don't send escape
self.asModifier = hs.eventtap.new({ hs.eventtap.event.types.keyDown }, function(_) self.asModifier = hs.eventtap.new({ hs.eventtap.event.types.keyDown }, function(_)
self.sendEscape = false self.sendEscape = false
-- print("Don't sent escape") print("Don't sent escape")
end) end)
-- If mouse is moving significantly, don't send escape -- If mouse is moving significantly, don't send escape

View File

@ -56,13 +56,13 @@ function obj:init()
-- Launcher shortcuts -- Launcher shortcuts
self.launcher:bind("ctrl", "space", function() end) self.launcher:bind("ctrl", "space", function() end)
self.launcher:bind("", "return", function() self.launcher:bind("", "return", function()
self:switch("@kitty@") self:switch("Alacritty.app")
end) end)
self.launcher:bind("", "C", function() self.launcher:bind("", "C", function()
self:switch("Calendar.app") self:switch("Calendar.app")
end) end)
self.launcher:bind("", "D", function() self.launcher:bind("", "D", function()
self:switch("@discord@") self:switch("Discord.app")
end) end)
self.launcher:bind("", "E", function() self.launcher:bind("", "E", function()
self:switch("Mail.app") self:switch("Mail.app")
@ -71,7 +71,7 @@ function obj:init()
self:switch("Music.app") self:switch("Music.app")
end) end)
self.launcher:bind("", "F", function() self.launcher:bind("", "F", function()
self:switch("@firefox@") self:switch("Firefox.app")
end) end)
self.launcher:bind("", "H", function() self.launcher:bind("", "H", function()
self:switch("Hammerspoon.app") self:switch("Hammerspoon.app")

View File

@ -9,25 +9,24 @@ WORK_RIGHT_MONITOR = "DELL U2415 (1)"
LAPTOP_MONITOR = "Built-in Retina Display" LAPTOP_MONITOR = "Built-in Retina Display"
-- Used to find out the name of the monitor in Hammerspoon -- Used to find out the name of the monitor in Hammerspoon
-- local function dump(o) function dump(o)
-- if type(o) == "table" then if type(o) == "table" then
-- local s = "{ " local s = "{ "
-- for k, v in pairs(o) do for k, v in pairs(o) do
-- if type(k) ~= "number" then if type(k) ~= "number" then
-- k = '"' .. k .. '"' k = '"' .. k .. '"'
-- end end
-- s = s .. "[" .. k .. "] = " .. dump(v) .. "," s = s .. "[" .. k .. "] = " .. dump(v) .. ","
-- end end
-- return s .. "} " return s .. "} "
-- else else
-- return tostring(o) return tostring(o)
-- end end
-- end end
-- Turn on when looking for the monitor name -- Turn on when looking for the monitor name
-- print(dump(hs.screen.allScreens())) -- print(dump(hs.screen.allScreens()))
local function concat(...) function concat(...)
local res = {} local res = {}
for _, tab in ipairs({ ... }) do for _, tab in ipairs({ ... }) do
for _, elem in ipairs(tab) do for _, elem in ipairs(tab) do
@ -37,12 +36,12 @@ local function concat(...)
return res return res
end end
local function worklayout() function worklayout()
hs.hotkey.bind({ "alt", "ctrl", "cmd" }, "l", function() hs.hotkey.bind({ "alt", "ctrl", "cmd" }, "l", function()
local u = hs.geometry.unitrect local u = hs.geometry.unitrect
-- set the layout -- set the layout
local left = { local left = {
{ "kitty", nil, WORK_LEFT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, -- { "Alacritty", nil, WORK_LEFT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true },
} }
local right = { local right = {
{ "Slack", nil, WORK_RIGHT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, { "Slack", nil, WORK_RIGHT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true },

View File

@ -1,55 +1,51 @@
{ config, pkgs, lib, ... }: { { config, ... }: {
# Homebrew - Mac-specific packages that aren't in Nix # Homebrew - Mac-specific packages that aren't in Nix
config = lib.mkIf pkgs.stdenv.isDarwin {
# Requires Homebrew to be installed # Requires Homebrew to be installed
system.activationScripts.preUserActivation.text = '' system.activationScripts.preUserActivation.text = ''
if ! xcode-select --version 2>/dev/null; then if ! xcode-select --version 2>/dev/null; then
$DRY_RUN_CMD xcode-select --install $DRY_RUN_CMD xcode-select --install
fi fi
if ! /usr/local/bin/brew --version 2>/dev/null; then if ! /usr/local/bin/brew --version 2>/dev/null; then
$DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" $DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi fi
''; '';
homebrew = { homebrew = {
enable = true; enable = true;
onActivation = { onActivation = {
autoUpdate = false; # Don't update during rebuild autoUpdate = false; # Don't update during rebuild
cleanup = "zap"; # Uninstall all programs not declared cleanup = "zap"; # Uninstall all programs not declared
upgrade = true; upgrade = true;
};
global = {
brewfile = true; # Run brew bundle from anywhere
lockfiles = false; # Don't save lockfile (since running from anywhere)
};
taps = [
"homebrew/cask" # Required for casks
"homebrew/cask-drivers" # Used for Logitech G-Hub
];
brews = [
"trash" # Delete files and folders to trash instead of rm
"openjdk" # Required by Apache Directory Studio
];
casks = [
"1password" # 1Password packaging on Nix is broken for macOS
"scroll-reverser" # Different scroll style for mouse vs. trackpad
"meetingbar" # Show meetings in menu bar
"gitify" # Git notifications in menu bar
"logitech-g-hub" # Mouse and keyboard management
"mimestream" # Gmail client
"obsidian" # Obsidian packaging on Nix is not available for macOS
"steam" # Not packaged for Nix
"apache-directory-studio" # Packaging on Nix is not available for macOS
];
}; };
global = {
home-manager.users.${config.user} = { brewfile = true; # Run brew bundle from anywhere
lockfiles = false; # Don't save lockfile (since running from anywhere)
programs.fish.shellAbbrs.t = "trash";
}; };
taps = [
"homebrew/cask" # Required for casks
"homebrew/cask-drivers" # Used for Logitech G-Hub
];
brews = [
"trash" # Delete files and folders to trash instead of rm
];
casks = [
"firefox" # Firefox packaging on Nix is broken for MacOS
"1password" # 1Password packaging on Nix is broken for MacOS
"scroll-reverser" # Different scroll style for mouse vs. trackpad
"meetingbar" # Show meetings in menu bar
"gitify" # Git notifications in menu bar
"logitech-g-hub" # Mouse and keyboard management
"mimestream" # Gmail client
"obsidian" # Obsidian packaging on Nix is not available for MacOS
"steam" # Not packaged for Nix
];
};
home-manager.users.${config.user} = {
programs.fish.shellAbbrs.t = "trash";
}; };

View File

@ -1,18 +0,0 @@
{ config, pkgs, lib, ... }: {
# MacOS-specific settings for Kitty
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
programs.kitty = {
darwinLaunchOptions = [ "--start-as=fullscreen" ];
font.size = lib.mkForce 20;
settings = {
shell = "/run/current-system/sw/bin/fish";
macos_traditional_fullscreen = true;
macos_quit_when_last_window_closed = true;
disable_ligatures = "always";
macos_option_as_alt = true;
};
};
};
}

View File

@ -1,11 +1,8 @@
{ config, pkgs, lib, ... }: { { ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin { networking = {
networking = { computerName = "MacBook"; # Host name
computerName = "${config.fullName}'\\''s Mac"; hostName = "MacBook";
# Adjust if necessary
# hostName = "";
};
}; };
} }

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }: { { config, lib, ... }: {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { home-manager.users.${config.user} = {
programs.fish = { programs.fish = {
shellAbbrs = { shellAbbrs = {
@ -18,13 +18,6 @@
commandline --function execute commandline --function execute
''; '';
}; };
rebuild-home = lib.mkForce {
body = ''
git -C ${config.dotfilesPath} add --intent-to-add --all
commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#macbook";
commandline --function execute
'';
};
}; };
}; };

11
modules/darwin/ssl.nix Normal file
View File

@ -0,0 +1,11 @@
{ config, pkgs, ... }: {
# security.pki.certificateFiles = [
# "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
# (builtins.toString ../work/nixos-org-certs.crt)
# ];
security.pki.certificates =
[ (builtins.readFile ../work/nixos-org-certs.crt) ];
}

View File

@ -1,186 +1,183 @@
{ pkgs, lib, ... }: { { ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin { services.nix-daemon.enable = true;
services.nix-daemon.enable = true; system = {
environment.shells = [ pkgs.fish ]; keyboard = {
remapCapsLockToControl = true;
enableKeyMapping = true; # Allows for skhd
};
security.pam.enableSudoTouchIdAuth = true; defaults = {
NSGlobalDomain = {
system = { # Set to dark mode
AppleInterfaceStyle = "Dark";
keyboard = { # Don't change from dark to light automatically
remapCapsLockToControl = true; # AppleInterfaceSwitchesAutomatically = false;
enableKeyMapping = true; # Allows for skhd
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
AppleKeyboardUIMode = 3;
# Automatically show and hide the menu bar
_HIHideMenuBar = true;
# Expand save panel by default
NSNavPanelExpandedStateForSaveMode = true;
# Expand print panel by default
PMPrintingExpandedStateForPrint = true;
# Replace press-and-hold with key repeat
ApplePressAndHoldEnabled = false;
# Set a fast key repeat rate
KeyRepeat = 2;
# Shorten delay before key repeat begins
InitialKeyRepeat = 12;
# Save to local disk by default, not iCloud
NSDocumentSaveNewDocumentsToCloud = false;
# Disable autocorrect capitalization
NSAutomaticCapitalizationEnabled = false;
# Disable autocorrect smart dashes
NSAutomaticDashSubstitutionEnabled = false;
# Disable autocorrect adding periods
NSAutomaticPeriodSubstitutionEnabled = false;
# Disable autocorrect smart quotation marks
NSAutomaticQuoteSubstitutionEnabled = false;
# Disable autocorrect spellcheck
NSAutomaticSpellingCorrectionEnabled = false;
}; };
defaults = { dock = {
NSGlobalDomain = { # Automatically show and hide the dock
autohide = true;
# Set to dark mode # Add translucency in dock for hidden applications
AppleInterfaceStyle = "Dark"; showhidden = true;
# Don't change from dark to light automatically # Enable spring loading on all dock items
# AppleInterfaceSwitchesAutomatically = false; enable-spring-load-actions-on-all-items = true;
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs) # Highlight hover effect in dock stack grid view
AppleKeyboardUIMode = 3; mouse-over-hilite-stack = true;
# Automatically show and hide the menu bar mineffect = "genie";
_HIHideMenuBar = true; orientation = "bottom";
show-recents = false;
tilesize = 44;
};
# Expand save panel by default finder = {
NSNavPanelExpandedStateForSaveMode = true;
# Expand print panel by default # Default Finder window set to column view
PMPrintingExpandedStateForPrint = true; FXPreferredViewStyle = "clmv";
# Replace press-and-hold with key repeat # Finder search in current folder by default
ApplePressAndHoldEnabled = false; FXDefaultSearchScope = "SCcf";
# Set a fast key repeat rate # Disable warning when changing file extension
KeyRepeat = 2; FXEnableExtensionChangeWarning = false;
# Shorten delay before key repeat begins # Allow quitting of Finder application
InitialKeyRepeat = 12; QuitMenuItem = true;
# Save to local disk by default, not iCloud
NSDocumentSaveNewDocumentsToCloud = false;
# Disable autocorrect capitalization
NSAutomaticCapitalizationEnabled = false;
# Disable autocorrect smart dashes
NSAutomaticDashSubstitutionEnabled = false;
# Disable autocorrect adding periods
NSAutomaticPeriodSubstitutionEnabled = false;
# Disable autocorrect smart quotation marks
NSAutomaticQuoteSubstitutionEnabled = false;
# Disable autocorrect spellcheck
NSAutomaticSpellingCorrectionEnabled = false;
};
dock = {
# Automatically show and hide the dock
autohide = true;
# Add translucency in dock for hidden applications
showhidden = true;
# Enable spring loading on all dock items
enable-spring-load-actions-on-all-items = true;
# Highlight hover effect in dock stack grid view
mouse-over-hilite-stack = true;
mineffect = "genie";
orientation = "bottom";
show-recents = false;
tilesize = 44;
};
finder = {
# Default Finder window set to column view
FXPreferredViewStyle = "clmv";
# Finder search in current folder by default
FXDefaultSearchScope = "SCcf";
# Disable warning when changing file extension
FXEnableExtensionChangeWarning = false;
# Allow quitting of Finder application
QuitMenuItem = true;
};
# Disable "Are you sure you want to open" dialog
LaunchServices.LSQuarantine = false;
# Disable trackpad tap to click
trackpad.Clicking = false;
# universalaccess = {
# # Zoom in with Control + Scroll Wheel
# closeViewScrollWheelToggle = true;
# closeViewZoomFollowsFocus = true;
# };
# Where to save screenshots
screencapture.location = "~/Downloads";
}; };
# Settings that don't have an option in nix-darwin # Disable "Are you sure you want to open" dialog
activationScripts.postActivation.text = '' LaunchServices.LSQuarantine = false;
echo "Disable disk image verification"
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
echo "Avoid creating .DS_Store files on network volumes" # Disable trackpad tap to click
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true trackpad.Clicking = false;
echo "Disable the warning before emptying the Trash" # universalaccess = {
defaults write com.apple.finder WarnOnEmptyTrash -bool false
echo "Require password immediately after sleep or screen saver begins" # # Zoom in with Control + Scroll Wheel
defaults write com.apple.screensaver askForPassword -int 1 # closeViewScrollWheelToggle = true;
defaults write com.apple.screensaver askForPasswordDelay -int 0 # closeViewZoomFollowsFocus = true;
# };
echo "Allow apps from anywhere" # Where to save screenshots
SPCTL=$(spctl --status) screencapture.location = "~/Downloads";
if ! [ "$SPCTL" = "assessments disabled" ]; then
sudo spctl --master-disable
fi
'';
# User-level settings
activationScripts.postUserActivation.text = ''
echo "Show the ~/Library folder"
chflags nohidden ~/Library
echo "Enable dock magnification"
defaults write com.apple.dock magnification -bool true
echo "Set dock magnification size"
defaults write com.apple.dock largesize -int 48
echo "Define dock icon function"
__dock_item() {
printf "%s%s%s%s%s" \
"<dict><key>tile-data</key><dict><key>file-data</key><dict>" \
"<key>_CFURLString</key><string>" \
"$1" \
"</string><key>_CFURLStringType</key><integer>0</integer>" \
"</dict></dict></dict>"
}
echo "Choose and order dock icons"
defaults write com.apple.dock persistent-apps -array \
"$(__dock_item /Applications/1Password.app)" \
"$(__dock_item /Applications/Slack.app)" \
"$(__dock_item /System/Applications/Calendar.app)" \
"$(__dock_item ${pkgs.firefox-bin}/Applications/Firefox.app)" \
"$(__dock_item /System/Applications/Messages.app)" \
"$(__dock_item /System/Applications/Mail.app)" \
"$(__dock_item /Applications/Mimestream.app)" \
"$(__dock_item /Applications/zoom.us.app)" \
"$(__dock_item ${pkgs.discord}/Applications/Discord.app)" \
"$(__dock_item /Applications/Obsidian.app)" \
"$(__dock_item ${pkgs.kitty}/Applications/kitty.app)" \
"$(__dock_item /System/Applications/System\ Settings.app)"
'';
}; };
# Settings that don't have an option in nix-darwin
activationScripts.postActivation.text = ''
echo "Disable disk image verification"
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
echo "Avoid creating .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
echo "Disable the warning before emptying the Trash"
defaults write com.apple.finder WarnOnEmptyTrash -bool false
echo "Require password immediately after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
echo "Show the ~/Library folder"
chflags nohidden ~/Library
echo "Enable dock magnification"
defaults write com.apple.dock magnification -bool true
echo "Set dock magnification size"
defaults write com.apple.dock largesize -int 48
echo "Define dock icon function"
__dock_item() {
printf '%s%s%s%s%s' \
'<dict><key>tile-data</key><dict><key>file-data</key><dict>' \
'<key>_CFURLString</key><string>' \
"$1" \
'</string><key>_CFURLStringType</key><integer>0</integer>' \
'</dict></dict></dict>'
}
echo "Choose and order dock icons"
defaults write com.apple.dock persistent-apps -array \
"$(__dock_item /Applications/1Password.app)" \
"$(__dock_item /Applications/Slack.app)" \
"$(__dock_item /System/Applications/Calendar.app)" \
"$(__dock_item /Applications/Firefox.app)" \
"$(__dock_item /System/Applications/Messages.app)" \
"$(__dock_item /System/Applications/Mail.app)" \
"$(__dock_item /Applications/Mimestream.app)" \
"$(__dock_item /Applications/zoom.us.app)" \
"$(__dock_item /Applications/Obsidian.app)" \
"$(__dock_item /Applications/Alacritty.app)" \
"$(__dock_item /System/Applications/System\ Preferences.app)"
echo "Enable sudo Touch ID"
echo "# sudo: auth account password session" > /tmp/sudofile
echo "auth sufficient pam_smartcard.so" >> /tmp/sudofile
echo "auth sufficient pam_tid.so " >> /tmp/sudofile
echo "auth required pam_opendirectory.so" >> /tmp/sudofile
echo "account required pam_permit.so" >> /tmp/sudofile
echo "password required pam_deny.so" >> /tmp/sudofile
echo "session required pam_permit.so" >> /tmp/sudofile
sudo mv /tmp/sudofile /etc/pam.d/sudo
echo "Allow apps from anywhere"
SPCTL=$(spctl --status)
if ! [ "$SPCTL" = "assessments disabled" ]; then
sudo spctl --master-disable
fi
'';
}; };
} }

View File

@ -1,8 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, ... }: {
options.tmux.enable = lib.mkEnableOption "Tmux terminal multiplexer"; home-manager.users.${config.user} = {
config.home-manager.users.${config.user} = lib.mkIf config.tmux.enable {
programs.tmux = { programs.tmux = {
enable = true; enable = true;

View File

@ -1,21 +1,8 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin { users.users."${config.user}" = { # macOS user
home = config.homePath;
users.users."${config.user}" = { shell = pkgs.zsh; # Default shell
# macOS user
home = config.homePath;
shell = pkgs.fish; # Default shell
};
# Used for aerc
home-manager.users.${config.user} = {
home.sessionVariables = {
XDG_CONFIG_HOME = "${config.homePath}/.config";
};
};
}; };
} }

View File

@ -1,21 +1,6 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }: {
let home-manager.users.${config.user} = {
# Quickly package shell scripts with their dependencies
# From https://discourse.nixos.org/t/how-to-create-a-script-with-dependencies/7970/6
mkScript = { name, file, env ? [ ] }:
pkgs.writeScriptBin name ''
for i in ${lib.concatStringsSep " " env}; do
export PATH="$i/bin:$PATH"
done
exec ${pkgs.bash}/bin/bash ${file} $@
'';
in {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
home.packages = with pkgs; [ home.packages = with pkgs; [
# visidata # CSV inspector # visidata # CSV inspector
@ -26,17 +11,12 @@ in {
mpd # TUI slideshows mpd # TUI slideshows
awscli2 awscli2
awslogs awslogs
google-cloud-sdk kubectl
ansible k9s
vault
consul
noti # Create notifications programmatically noti # Create notifications programmatically
ipcalc # Make IP network calculations ipcalc
(mkScript { (pkgs.writeScriptBin "ocr"
name = "ocr"; (builtins.readFile ../shell/bash/scripts/ocr.sh))
file = ../shell/bash/scripts/ocr.sh;
env = [ tesseract ];
})
]; ];
programs.fish.shellAbbrs = { programs.fish.shellAbbrs = {

View File

@ -1,16 +1,8 @@
{ config, pkgs, lib, ... }: { { config, ... }: {
imports = [ imports = [ ./leagueoflegends.nix ./lutris.nix ./steam.nix ./legendary.nix ];
./leagueoflegends.nix
./legendary.nix
./lutris.nix
./minecraft-server.nix
./steam.nix
];
options.gaming.enable = lib.mkEnableOption "Enable gaming features."; config = {
config = lib.mkIf (config.gaming.enable && pkgs.stdenv.isLinux) {
hardware.opengl = { hardware.opengl = {
enable = true; enable = true;
driSupport32Bit = true; driSupport32Bit = true;

View File

@ -1,32 +1,30 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options.gaming.leagueoflegends.enable = options.gaming.leagueoflegends = lib.mkEnableOption "League of Legends";
lib.mkEnableOption "League of Legends";
config = config = lib.mkIf config.gaming.leagueoflegends {
lib.mkIf (config.gaming.leagueoflegends.enable && pkgs.stdenv.isLinux) {
# League of Legends anti-cheat requirement # League of Legends anti-cheat requirement
boot.kernel.sysctl = { "abi.vsyscall32" = 0; }; boot.kernel.sysctl = { "abi.vsyscall32" = 0; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
# Lutris requirement to install the game # Lutris requirement to install the game
lutris lutris
amdvlk amdvlk
wineWowPackages.stable wineWowPackages.stable
# vulkan-tools # vulkan-tools
# Required according to https://lutris.net/games/league-of-legends/ # Required according to https://lutris.net/games/league-of-legends/
openssl openssl
gnome.zenity gnome.zenity
# Don't remember if this is required # Don't remember if this is required
dconf dconf
]; ];
environment.sessionVariables = { QT_X11_NO_MITSHM = "1"; }; environment.sessionVariables = { QT_X11_NO_MITSHM = "1"; };
}; };
} }

View File

@ -4,10 +4,10 @@ let home-packages = config.home-manager.users.${config.user}.home.packages;
in { in {
options.gaming.legendary.enable = options.gaming.legendary =
lib.mkEnableOption "Legendary Epic Games launcher."; lib.mkEnableOption "Legendary - Epic Games Launcher";
config = lib.mkIf config.gaming.legendary.enable { config = lib.mkIf config.gaming.legendary {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
legendary-gl legendary-gl
rare # GUI for Legendary (not working) rare # GUI for Legendary (not working)

View File

@ -1,8 +1,8 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options.gaming.lutris.enable = lib.mkEnableOption "Lutris game installer."; options.gaming.lutris = lib.mkEnableOption "Lutris";
config = lib.mkIf config.gaming.lutris.enable { config = lib.mkIf config.gaming.lutris {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
lutris lutris
amdvlk # Vulkan drivers (probably already installed) amdvlk # Vulkan drivers (probably already installed)

View File

@ -1,152 +0,0 @@
{ config, pkgs, lib, ... }:
let
localPort = 25564;
publicPort = 49732;
rconPort = 25575;
rconPassword = "thiscanbeanything";
in {
options.gaming.minecraft-server.enable =
lib.mkEnableOption "Minecraft Server.";
config = lib.mkIf config.gaming.minecraft-server.enable {
unfreePackages = [ "minecraft-server" ];
services.minecraft-server = {
enable = true;
eula = true;
declarative = true;
whitelist = { };
openFirewall = false;
serverProperties = {
server-port = localPort;
difficulty = "normal";
gamemode = "survival";
white-list = false;
enforce-whitelist = false;
level-name = "world";
motd = "Welcome!";
pvp = true;
player-idle-timeout = 30;
generate-structures = true;
max-players = 20;
snooper-enabled = false;
spawn-npcs = true;
spawn-animals = true;
spawn-monsters = true;
allow-nether = true;
allow-flight = false;
enable-rcon = true;
"rcon.port" = rconPort;
"rcon.password" = rconPassword;
};
};
networking.firewall.allowedTCPPorts = [ publicPort ];
## Automatically start and stop Minecraft server based on player connections
# Adapted shamelessly from:
# https://dataswamp.org/~solene/2022-08-20-on-demand-minecraft-with-systemd.html
# Prevent Minecraft from starting by default
systemd.services.minecraft-server = { wantedBy = pkgs.lib.mkForce [ ]; };
# Listen for connections on the public port, to trigger the actual
# listen-minecraft service.
systemd.sockets.listen-minecraft = {
wantedBy = [ "sockets.target" ];
requires = [ "network.target" ];
listenStreams = [ "${toString publicPort}" ];
};
# Proxy traffic to local port, and trigger hook-minecraft
systemd.services.listen-minecraft = {
path = [ pkgs.systemd ];
requires = [ "hook-minecraft.service" "listen-minecraft.socket" ];
after = [ "hook-minecraft.service" "listen-minecraft.socket" ];
serviceConfig.ExecStart =
"${pkgs.systemd.out}/lib/systemd/systemd-socket-proxyd 127.0.0.1:${
toString localPort
}";
};
# Start Minecraft if required and wait for it to be available
# Then unlock the listen-minecraft.service
systemd.services.hook-minecraft = {
path = with pkgs; [ systemd libressl busybox ];
# Start Minecraft and the auto-shutdown timer
script = ''
systemctl start minecraft-server.service
systemctl start stop-minecraft.timer
'';
# Keep checking until the service is available
postStart = ''
for i in $(seq 60); do
if ${pkgs.libressl.nc}/bin/nc -z 127.0.0.1 ${
toString localPort
} > /dev/null ; then
exit 0
fi
${pkgs.busybox.out}/bin/sleep 1
done
exit 1
'';
};
# Run a player check on a schedule for auto-shutdown
systemd.timers.stop-minecraft = {
timerConfig = {
OnCalendar = "*-*-* *:*:0/20"; # Every 20 seconds
Unit = "stop-minecraft.service";
};
};
# If no players are connected, then stop services and prepare to resume again
systemd.services.stop-minecraft = {
serviceConfig.Type = "oneshot";
script = ''
# Check when service was launched
servicestartsec=$(
date -d \
"$(systemctl show \
--property=ActiveEnterTimestamp \
minecraft-server.service \
| cut -d= -f2)" \
+%s)
# Calculate elapsed time
serviceelapsedsec=$(( $(date +%s) - servicestartsec))
# Ignore if service just started
if [ $serviceelapsedsec -lt 180 ]
then
echo "Server was just started"
exit 0
fi
PLAYERS=$(
printf "list\n" \
| ${pkgs.rcon.out}/bin/rcon -m \
-H 127.0.0.1 -p ${builtins.toString rconPort} -P ${rconPassword} \
)
if echo "$PLAYERS" | grep "are 0 of a"
then
echo "Stopping server"
systemctl stop minecraft-server.service
systemctl stop hook-minecraft.service
systemctl stop stop-minecraft.timer
fi
'';
};
};
}

View File

@ -1,10 +1,10 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
options.gaming.steam.enable = lib.mkEnableOption "Steam game launcher."; options.gaming.steam = lib.mkEnableOption "Steam";
config = lib.mkIf (config.gaming.steam.enable && pkgs.stdenv.isLinux) { config = lib.mkIf config.gaming.steam {
hardware.steam-hardware.enable = true; hardware.steam-hardware.enable = true;
unfreePackages = [ "steam" "steam-original" "steamcmd" "steam-run" ]; unfreePackages = [ "steam" "steam-original" "steamcmd" ];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
steam steam

View File

@ -1,29 +1,53 @@
{ lib, ... }: { { lib, ... }: {
imports = imports = [
[ ./xorg.nix ./fonts.nix ./i3.nix ./polybar.nix ./picom.nix ./rofi.nix ]; ./xorg.nix
./fonts.nix
./i3.nix
./polybar.nix
./picom.nix
# ./dmenu.nix
./rofi.nix
];
options = { options = with lib; {
launcherCommand = lib.mkOption { gui = {
type = lib.types.str; compositor.enable = mkEnableOption {
description = "Command to use for launching"; description = "Enable transparency, blur, shadows";
}; default = false;
systemdSearch = lib.mkOption { };
type = lib.types.str; launcherCommand = mkOption {
description = "Command to use for interacting with systemd"; type = types.str;
}; description = "Command to use for launching";
altTabCommand = lib.mkOption { };
type = lib.types.str; systemdSearch = mkOption {
description = "Command to use for choosing windows"; type = types.str;
}; description = "Command to use for interacting with systemd";
toggleBarCommand = lib.mkOption { };
type = lib.types.str; altTabCommand = mkOption {
description = "Command to hide and show the status bar."; type = types.str;
}; description = "Command to use for choosing windows";
wallpaper = lib.mkOption { };
type = lib.types.path; toggleBarCommand = lib.mkOption {
description = "Wallpaper background image file"; type = lib.types.str;
description = "Command to hide and show the status bar.";
};
gtk.theme = {
name = mkOption {
type = types.str;
description = "Theme name for GTK applications";
};
package = mkOption {
type = types.str;
description = "Theme package name for GTK applications";
default = "gnome-themes-extra";
};
};
wallpaper = mkOption {
type = types.path;
description = "Wallpaper background image file";
};
}; };
}; };

View File

@ -2,9 +2,7 @@
{ {
options.gui.dmenu.enable = lib.mkEnableOption "dmenu launcher."; config = lib.mkIf config.services.xserver.enable {
config = lib.mkIf (config.services.xserver.enable && config.dmenu.enable) {
home-manager.users.${config.user}.home.packages = [ pkgs.dmenu ]; home-manager.users.${config.user}.home.packages = [ pkgs.dmenu ];
gui.launcherCommand = "${pkgs.dmenu}/bin/dmenu_run"; gui.launcherCommand = "${pkgs.dmenu}/bin/dmenu_run";

View File

@ -4,7 +4,7 @@ let fontName = "Victor Mono";
in { in {
config = lib.mkIf (config.gui.enable && pkgs.stdenv.isLinux) { config = lib.mkIf config.gui.enable {
fonts.fonts = with pkgs; [ fonts.fonts = with pkgs; [
victor-mono # Used for Vim and Terminal victor-mono # Used for Vim and Terminal
@ -21,7 +21,6 @@ in {
services.polybar.config."bar/main".font-0 = "Hack Nerd Font:size=10;2"; services.polybar.config."bar/main".font-0 = "Hack Nerd Font:size=10;2";
programs.rofi.font = "Hack Nerd Font 14"; programs.rofi.font = "Hack Nerd Font 14";
programs.alacritty.settings.font.normal.family = fontName; programs.alacritty.settings.font.normal.family = fontName;
programs.kitty.font.name = fontName;
}; };
}; };

View File

@ -5,15 +5,15 @@ let
lockCmd = lockCmd =
"${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span"; "${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span";
lockUpdate = lockUpdate =
"${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.wallpaper} --display 1 --span"; "${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.gui.wallpaper} --display 1 --span";
in { in {
config = lib.mkIf pkgs.stdenv.isLinux { config = lib.mkIf config.services.xserver.enable {
services.xserver.windowManager = { services.xserver.windowManager = {
i3 = { i3 = {
enable = config.services.xserver.enable; enable = true;
package = pkgs.i3-gaps; package = pkgs.i3-gaps;
}; };
}; };
@ -25,7 +25,7 @@ in {
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
xsession.windowManager.i3 = { xsession.windowManager.i3 = {
enable = config.services.xserver.enable; enable = true;
package = pkgs.i3-gaps; package = pkgs.i3-gaps;
config = let config = let
modifier = "Mod4"; # Super key modifier = "Mod4"; # Super key
@ -43,22 +43,22 @@ in {
modifier = modifier; modifier = modifier;
assigns = { assigns = {
"${ws1}" = [{ class = "Firefox"; }]; "${ws1}" = [{ class = "Firefox"; }];
"${ws2}" = [{ class = "kitty"; }]; "${ws2}" = [{ class = "Alacritty"; }];
"${ws3}" = [{ class = "discord"; }]; "${ws3}" = [{ class = "discord"; }];
"${ws4}" = [{ class = "Steam"; }]; "${ws4}" = [{ class = "Steam"; }];
}; };
bars = [{ command = "echo"; }]; # Disable i3bar bars = [{ command = "echo"; }]; # Disable i3bar
colors = let colors = let
background = config.theme.colors.base00; background = config.colorscheme.base00;
inactiveBackground = config.theme.colors.base01; inactiveBackground = config.colorscheme.base01;
border = config.theme.colors.base01; border = config.colorscheme.base01;
inactiveBorder = config.theme.colors.base01; inactiveBorder = config.colorscheme.base01;
text = config.theme.colors.base07; text = config.colorscheme.base07;
inactiveText = config.theme.colors.base04; inactiveText = config.colorscheme.base04;
urgentBackground = config.theme.colors.base08; urgentBackground = config.colorscheme.base08;
indicator = "#00000000"; indicator = "#00000000";
in { in {
background = config.theme.colors.base00; background = config.colorscheme.base00;
focused = { focused = {
inherit background indicator text border; inherit background indicator text border;
childBorder = background; childBorder = background;
@ -111,12 +111,12 @@ in {
# Launchers # Launchers
"${modifier}+Return" = "${modifier}+Return" =
"exec --no-startup-id kitty; workspace ${ws2}; layout tabbed"; "exec --no-startup-id alacritty; workspace ${ws2}; layout tabbed";
"${modifier}+space" = "${modifier}+space" =
"exec --no-startup-id ${config.launcherCommand}"; "exec --no-startup-id ${config.gui.launcherCommand}";
"${modifier}+Shift+s" = "${modifier}+Shift+s" =
"exec --no-startup-id ${config.systemdSearch}"; "exec --no-startup-id ${config.gui.systemdSearch}";
"Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}"; "Mod1+Tab" = "exec --no-startup-id ${config.gui.altTabCommand}";
"${modifier}+Shift+c" = "reload"; "${modifier}+Shift+c" = "reload";
"${modifier}+Shift+r" = "restart"; "${modifier}+Shift+r" = "restart";
"${modifier}+Shift+q" = '' "${modifier}+Shift+q" = ''
@ -125,7 +125,7 @@ in {
# Window options # Window options
"${modifier}+q" = "kill"; "${modifier}+q" = "kill";
"${modifier}+b" = "exec ${config.toggleBarCommand}"; "${modifier}+b" = "exec ${config.gui.toggleBarCommand}";
"${modifier}+f" = "fullscreen toggle"; "${modifier}+f" = "fullscreen toggle";
"${modifier}+h" = "focus left"; "${modifier}+h" = "focus left";
"${modifier}+j" = "focus down"; "${modifier}+j" = "focus down";
@ -205,18 +205,12 @@ in {
modes = { }; modes = { };
startup = [ startup = [
{ {
command = "feh --bg-fill ${config.wallpaper}"; command = "feh --bg-fill ${config.gui.wallpaper}";
always = true; always = true;
notification = false; notification = false;
} }
{ {
command = command = "i3-msg workspace ${ws1}";
"i3-msg workspace ${ws2}, move workspace to output right";
notification = false;
}
{
command =
"i3-msg workspace ${ws1}, move workspace to output left";
notification = false; notification = false;
} }
]; ];
@ -244,7 +238,7 @@ in {
}; };
programs.fish.functions = { programs.fish.functions = {
update-lock-screen = lib.mkIf config.services.xserver.enable { update-lock-screen = {
description = "Update lockscreen with wallpaper"; description = "Update lockscreen with wallpaper";
body = lockUpdate; body = lockUpdate;
}; };
@ -253,19 +247,17 @@ in {
# Update lock screen cache only if cache is empty # Update lock screen cache only if cache is empty
home.activation.updateLockScreenCache = home.activation.updateLockScreenCache =
let cacheDir = "${config.homePath}/.cache/betterlockscreen/current"; let cacheDir = "${config.homePath}/.cache/betterlockscreen/current";
in lib.mkIf config.services.xserver.enable in config.home-manager.users.${config.user}.lib.dag.entryAfter
(config.home-manager.users.${config.user}.lib.dag.entryAfter [ "writeBoundary" ] ''
[ "writeBoundary" ] '' if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then
if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then $DRY_RUN_CMD ${lockUpdate}
$DRY_RUN_CMD ${lockUpdate} fi
fi '';
'');
}; };
# Ref: https://github.com/betterlockscreen/betterlockscreen/blob/next/system/betterlockscreen%40.service # Ref: https://github.com/betterlockscreen/betterlockscreen/blob/next/system/betterlockscreen%40.service
systemd.services.lock = { systemd.services.lock = {
enable = config.services.xserver.enable;
description = "Lock the screen on resume from suspend"; description = "Lock the screen on resume from suspend";
before = [ "sleep.target" "suspend.target" ]; before = [ "sleep.target" "suspend.target" ];
serviceConfig = { serviceConfig = {

View File

@ -1,49 +1,49 @@
{ config, pkgs, lib, ... }: { { config, lib, ... }: {
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { config =
home-manager.users.${config.user} = { lib.mkIf (config.services.xserver.enable && config.gui.compositor.enable) {
home-manager.users.${config.user} = {
services.picom = { services.picom = {
enable = true; enable = true;
backend = "glx"; settings = {
settings = { blur = false;
blur = false; blurExclude = [ ];
blurExclude = [ ]; inactiveDim = "0.05";
inactiveDim = "0.05"; noDNDShadow = false;
noDNDShadow = false; noDockShadow = false;
noDockShadow = false; # shadow-radius = 20
# shadow-radius = 20 # '';
# ''; # shadow-radius = 20
# shadow-radius = 20 # corner-radius = 10
# corner-radius = 10 # blur-size = 20
# blur-size = 20 # rounded-corners-exclude = [
# rounded-corners-exclude = [ # "window_type = 'dock'",
# "window_type = 'dock'", # "class_g = 'i3-frame'"
# "class_g = 'i3-frame'" # ]
# ] # '';
# ''; };
fade = false;
experimentalBackends = true;
inactiveOpacity = 1.0;
menuOpacity = 1.0;
opacityRules = [
"0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'" # Hide tabbed windows
];
shadow = false;
shadowExclude = [ ];
shadowOffsets = [ (-10) (-10) ];
shadowOpacity = 0.5;
vSync = true;
}; };
fade = false;
experimentalBackends = true; xsession.windowManager.i3.config.startup = [{
inactiveOpacity = 1.0; command = "systemctl --user restart picom";
menuOpacity = 1.0; always = true;
opacityRules = [ notification = false;
"0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'" # Hide tabbed windows }];
];
shadow = false;
shadowExclude = [ ];
shadowOffsets = [ (-10) (-10) ];
shadowOpacity = 0.5;
vSync = true;
}; };
xsession.windowManager.i3.config.startup = [{
command = "systemctl --user restart picom";
always = true;
notification = false;
}];
}; };
};
} }

View File

@ -1,8 +1,8 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { config = lib.mkIf config.services.xserver.enable {
toggleBarCommand = "polybar-msg cmd toggle"; gui.toggleBarCommand = "polybar-msg cmd toggle";
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
@ -23,14 +23,14 @@
# offset-y = -5; # offset-y = -5;
# offset-y = "5%"; # offset-y = "5%";
# dpi = 96; # dpi = 96;
background = config.theme.colors.base01; background = config.colorscheme.base01;
foreground = config.theme.colors.base05; foreground = config.colorscheme.base05;
line-size = "3pt"; line-size = "3pt";
border-top-size = 0; border-top-size = 0;
border-right-size = 0; border-right-size = 0;
border-left-size = 0; border-left-size = 0;
border-bottom-size = "4pt"; border-bottom-size = "4pt";
border-color = config.theme.colors.base00; border-color = config.colorscheme.base00;
padding-left = 2; padding-left = 2;
padding-right = 2; padding-right = 2;
module-margin = 1; module-margin = 1;
@ -58,35 +58,35 @@
fuzzy-match = true; fuzzy-match = true;
format = "<label-state> <label-mode>"; format = "<label-state> <label-mode>";
label-focused = "%name%"; label-focused = "%name%";
label-focused-foreground = config.theme.colors.base01; label-focused-foreground = config.colorscheme.base01;
label-focused-background = config.theme.colors.base05; label-focused-background = config.colorscheme.base05;
label-focused-underline = config.theme.colors.base03; label-focused-underline = config.colorscheme.base03;
label-focused-padding = padding; label-focused-padding = padding;
label-unfocused = "%name%"; label-unfocused = "%name%";
label-unfocused-padding = padding; label-unfocused-padding = padding;
label-visible = "%name%"; label-visible = "%name%";
label-visible-underline = config.theme.colors.base01; label-visible-underline = config.colorscheme.base01;
label-visible-padding = padding; label-visible-padding = padding;
label-urgent = "%name%"; label-urgent = "%name%";
label-urgent-foreground = config.theme.colors.base00; label-urgent-foreground = config.colorscheme.base00;
label-urgent-background = config.theme.colors.base08; label-urgent-background = config.colorscheme.base08;
label-urgent-underline = config.theme.colors.base0F; label-urgent-underline = config.colorscheme.base0F;
label-urgent-padding = padding; label-urgent-padding = padding;
}; };
"module/xworkspaces" = { "module/xworkspaces" = {
type = "internal/xworkspaces"; type = "internal/xworkspaces";
label-active = "%name%"; label-active = "%name%";
label-active-background = config.theme.colors.base05; label-active-background = config.colorscheme.base05;
label-active-foreground = config.theme.colors.base01; label-active-foreground = config.colorscheme.base01;
label-active-underline = config.theme.colors.base03; label-active-underline = config.colorscheme.base03;
label-active-padding = 1; label-active-padding = 1;
label-occupied = "%name%"; label-occupied = "%name%";
label-occupied-padding = 1; label-occupied-padding = 1;
label-urgent = "%name%"; label-urgent = "%name%";
label-urgent-background = config.theme.colors.base08; label-urgent-background = config.colorscheme.base08;
label-urgent-padding = 1; label-urgent-padding = 1;
label-empty = "%name%"; label-empty = "%name%";
label-empty-foreground = config.theme.colors.base06; label-empty-foreground = config.colorscheme.base06;
label-empty-padding = 1; label-empty-padding = 1;
}; };
"module/xwindow" = { "module/xwindow" = {
@ -108,10 +108,10 @@
format-volume = "<ramp-volume> <label-volume>"; format-volume = "<ramp-volume> <label-volume>";
# format-volume-background = colors.background; # format-volume-background = colors.background;
# label-volume-background = colors.background; # label-volume-background = colors.background;
format-volume-foreground = config.theme.colors.base0B; format-volume-foreground = config.colorscheme.base0B;
label-volume = "%percentage%%"; label-volume = "%percentage%%";
label-muted = " ---"; label-muted = " ---";
label-muted-foreground = config.theme.colors.base03; label-muted-foreground = config.colorscheme.base03;
ramp-volume-0 = ""; ramp-volume-0 = "";
ramp-volume-1 = ""; ramp-volume-1 = "";
ramp-volume-2 = ""; ramp-volume-2 = "";
@ -163,7 +163,7 @@
date = "%d %b %l:%M %p"; date = "%d %b %l:%M %p";
date-alt = "%Y-%m-%d %H:%M:%S"; date-alt = "%Y-%m-%d %H:%M:%S";
label = "%date%"; label = "%date%";
label-foreground = config.theme.colors.base0A; label-foreground = config.colorscheme.base0A;
# format-background = colors.background; # format-background = colors.background;
}; };
"settings" = { "settings" = {

View File

@ -2,7 +2,7 @@
{ {
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { config = lib.mkIf config.services.xserver.enable {
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
@ -25,19 +25,19 @@
# Inspired by https://github.com/sherubthakur/dotfiles/blob/master/users/modules/desktop-environment/rofi/launcher.rasi # Inspired by https://github.com/sherubthakur/dotfiles/blob/master/users/modules/desktop-environment/rofi/launcher.rasi
"*" = { "*" = {
background-color = mkLiteral config.theme.colors.base00; background-color = mkLiteral config.colorscheme.base00;
foreground-color = mkLiteral config.theme.colors.base07; foreground-color = mkLiteral config.colorscheme.base07;
text-color = mkLiteral config.theme.colors.base07; text-color = mkLiteral config.colorscheme.base07;
border-color = mkLiteral config.theme.colors.base04; border-color = mkLiteral config.colorscheme.base04;
}; };
# Holds the entire window # Holds the entire window
"#window" = { "#window" = {
transparency = "real"; transparency = "real";
background-color = mkLiteral config.theme.colors.base00; background-color = mkLiteral config.colorscheme.base00;
text-color = mkLiteral config.theme.colors.base07; text-color = mkLiteral config.colorscheme.base07;
border = mkLiteral "4px"; border = mkLiteral "4px";
border-color = mkLiteral config.theme.colors.base04; border-color = mkLiteral config.colorscheme.base04;
border-radius = mkLiteral "4px"; border-radius = mkLiteral "4px";
width = mkLiteral "850px"; width = mkLiteral "850px";
padding = mkLiteral "15px"; padding = mkLiteral "15px";
@ -45,10 +45,10 @@
# Wrapper around bar and results # Wrapper around bar and results
"#mainbox" = { "#mainbox" = {
background-color = mkLiteral config.theme.colors.base00; background-color = mkLiteral config.colorscheme.base00;
border = mkLiteral "0px"; border = mkLiteral "0px";
border-radius = mkLiteral "0px"; border-radius = mkLiteral "0px";
border-color = mkLiteral config.theme.colors.base04; border-color = mkLiteral config.colorscheme.base04;
children = map mkLiteral [ "inputbar" "listview" ]; children = map mkLiteral [ "inputbar" "listview" ];
spacing = mkLiteral "10px"; spacing = mkLiteral "10px";
padding = mkLiteral "10px"; padding = mkLiteral "10px";
@ -59,7 +59,7 @@
expand = false; expand = false;
str = ":"; str = ":";
margin = mkLiteral "0px 0.3em 0em 0em"; margin = mkLiteral "0px 0.3em 0em 0em";
text-color = mkLiteral config.theme.colors.base07; text-color = mkLiteral config.colorscheme.base07;
}; };
# Command prompt left of the input # Command prompt left of the input
@ -67,7 +67,7 @@
# Actual text box # Actual text box
"#entry" = { "#entry" = {
placeholder-color = mkLiteral config.theme.colors.base03; placeholder-color = mkLiteral config.colorscheme.base03;
expand = true; expand = true;
horizontal-align = "0"; horizontal-align = "0";
placeholder = "Launch Program"; placeholder = "Launch Program";
@ -85,7 +85,7 @@
# Results # Results
"#listview" = { "#listview" = {
background-color = mkLiteral config.theme.colors.base00; background-color = mkLiteral config.colorscheme.base00;
padding = mkLiteral "0px"; padding = mkLiteral "0px";
columns = 1; columns = 1;
lines = 12; lines = 12;
@ -104,9 +104,9 @@
"#element.selected" = { "#element.selected" = {
border = mkLiteral "1px"; border = mkLiteral "1px";
border-radius = mkLiteral "4px"; border-radius = mkLiteral "4px";
border-color = mkLiteral config.theme.colors.base07; border-color = mkLiteral config.colorscheme.base07;
background-color = mkLiteral config.theme.colors.base04; background-color = mkLiteral config.colorscheme.base04;
text-color = mkLiteral config.theme.colors.base00; text-color = mkLiteral config.colorscheme.base00;
}; };
"#element-text" = { "#element-text" = {
@ -116,8 +116,8 @@
margin = mkLiteral "0px 2.5px 0px 2.5px"; margin = mkLiteral "0px 2.5px 0px 2.5px";
}; };
"#element-text.selected" = { "#element-text.selected" = {
background-color = mkLiteral config.theme.colors.base04; background-color = mkLiteral config.colorscheme.base04;
text-color = mkLiteral config.theme.colors.base00; text-color = mkLiteral config.colorscheme.base00;
}; };
# Not sure how to get icons # Not sure how to get icons
@ -125,11 +125,11 @@
size = mkLiteral "18px"; size = mkLiteral "18px";
border = mkLiteral "0px"; border = mkLiteral "0px";
padding = mkLiteral "2px 5px 2px 2px"; padding = mkLiteral "2px 5px 2px 2px";
background-color = mkLiteral config.theme.colors.base00; background-color = mkLiteral config.colorscheme.base00;
}; };
"#element-icon.selected" = { "#element-icon.selected" = {
background-color = mkLiteral config.theme.colors.base04; background-color = mkLiteral config.colorscheme.base04;
text-color = mkLiteral config.theme.colors.base00; text-color = mkLiteral config.colorscheme.base00;
}; };
}; };
@ -144,9 +144,9 @@
}; };
launcherCommand = "${pkgs.rofi}/bin/rofi -show run -modi run"; gui.launcherCommand = "${pkgs.rofi}/bin/rofi -show run -modi run";
systemdSearch = "${pkgs.rofi-systemd}/bin/rofi-systemd"; gui.systemdSearch = "${pkgs.rofi-systemd}/bin/rofi-systemd";
altTabCommand = "${pkgs.rofi}/bin/rofi -show window -modi window"; gui.altTabCommand = "${pkgs.rofi}/bin/rofi -show window -modi window";
}; };

View File

@ -1,27 +1,15 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }:
options = { let
gtk.theme = {
name = lib.mkOption { gtkTheme = {
type = lib.types.str; name = config.gui.gtk.theme.name;
description = "Theme name for GTK applications"; package = pkgs.${config.gui.gtk.theme.package};
};
package = lib.mkOption {
type = lib.types.str;
description = "Theme package name for GTK applications";
default = "gnome-themes-extra";
};
};
}; };
config = let in {
gtkTheme = { config = lib.mkIf config.gui.enable {
name = config.gtk.theme.name;
package = pkgs."${config.gtk.theme.package}";
};
in lib.mkIf (pkgs.stdenv.isLinux && config.gui.enable) {
# Enable the X11 windowing system. # Enable the X11 windowing system.
services.xserver = { services.xserver = {
@ -34,16 +22,11 @@
displayManager = { displayManager = {
lightdm = { lightdm = {
enable = config.services.xserver.enable; enable = config.services.xserver.enable;
background = config.wallpaper; background = config.gui.wallpaper;
# Make the login screen dark # Make the login screen dark
greeters.gtk.theme = gtkTheme; greeters.gtk.theme = gtkTheme;
# Show default user
extraSeatDefaults = ''
greeter-hide-users = false
'';
}; };
}; };
@ -58,7 +41,7 @@
services.dbus.packages = [ pkgs.dconf ]; services.dbus.packages = [ pkgs.dconf ];
programs.dconf.enable = true; programs.dconf.enable = true;
environment.sessionVariables = { GTK_THEME = config.gtk.theme.name; }; environment.sessionVariables = { GTK_THEME = config.gui.gtk.theme.name; };
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
@ -67,10 +50,7 @@
pbpaste = "xclip -selection clipboard -out"; pbpaste = "xclip -selection clipboard -out";
}; };
gtk = let gtk = let gtkExtraConfig = { gtk-application-prefer-dark-theme = true; };
gtkExtraConfig = {
gtk-application-prefer-dark-theme = config.theme.dark;
};
in { in {
enable = true; enable = true;
theme = gtkTheme; theme = gtkTheme;

View File

@ -30,17 +30,11 @@ let
in { in {
config = lib.mkIf (pkgs.stdenv.isLinux && config.gui.enable) { config = lib.mkIf config.gui.enable {
sound.enable = true; sound.enable = true;
# Enable PipeWire # Enable PulseAudio
services.pipewire = { hardware.pulseaudio.enable = true;
enable = true;
pulse.enable = true;
};
# Provides audio source with background noise filtered
programs.noisetorch.enable = true;
# These aren't necessary, but helpful for the user # These aren't necessary, but helpful for the user
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
@ -58,8 +52,7 @@ in {
# Make sure that Volnoti actually starts (home-manager doesn't start # Make sure that Volnoti actually starts (home-manager doesn't start
# user daemon's automatically) # user daemon's automatically)
startup = [{ startup = [{
command = command = "systemctl --user restart volnoti";
"systemctl --user restart volnoti --alpha 0.15 --radius 40 --timeout 0.2";
always = true; always = true;
notification = false; notification = false;
}]; }];

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }: { { config, ... }: {
boot.loader = lib.mkIf (config.physical && pkgs.stdenv.isLinux) { boot.loader = {
grub = { grub = {
enable = true; enable = true;
@ -10,9 +10,6 @@
# Check for other OSes and make them available # Check for other OSes and make them available
useOSProber = true; useOSProber = true;
# Attempt to display GRUB on widescreen monitor
gfxmodeEfi = "1920x1080";
# Install GRUB onto the boot disk # Install GRUB onto the boot disk
# device = config.fileSystems."/boot".device; # device = config.fileSystems."/boot".device;

View File

@ -1,4 +1,4 @@
{ lib, ... }: { { ... }: {
imports = [ imports = [
./audio.nix ./audio.nix
@ -11,9 +11,4 @@
./wifi.nix ./wifi.nix
]; ];
options = {
physical = lib.mkEnableOption "Whether this machine is a physical device.";
server = lib.mkEnableOption "Whether this machine is a server.";
};
} }

View File

@ -3,52 +3,51 @@
# Timezone required for Redshift schedule # Timezone required for Redshift schedule
imports = [ ../nixos/timezone.nix ]; imports = [ ../nixos/timezone.nix ];
config = config = lib.mkIf config.gui.enable {
lib.mkIf (config.gui.enable && config.physical && pkgs.stdenv.isLinux) {
environment.systemPackages = with pkgs; environment.systemPackages = with pkgs;
[ [
ddcutil # Monitor brightness control ddcutil # Monitor brightness control
]; ];
# Reduce blue light at night # Reduce blue light at night
services.redshift = { services.redshift = {
enable = true; enable = true;
brightness = { brightness = {
day = "1.0"; day = "1.0";
night = "1.0"; night = "1.0";
};
}; };
# Detect monitors (brightness) for ddcutil
hardware.i2c.enable = true;
# Grant main user access to external monitors
users.users.${config.user}.extraGroups = [ "i2c" ];
services.xserver.displayManager = {
# Put the login screen on the left monitor
lightdm.greeters.gtk.extraConfig = ''
active-monitor=0
'';
# Set up screen position and rotation
setupCommands = ''
${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \
--mode 1920x1200 \
--pos 1920x0 \
--rotate left \
--output HDMI-0 \
--primary \
--mode 1920x1080 \
--pos 0x560 \
--rotate normal \
--output DVI-0 --off \
--output DVI-1 --off \
'';
};
}; };
# Detect monitors (brightness) for ddcutil
hardware.i2c.enable = true;
# Grant main user access to external monitors
users.users.${config.user}.extraGroups = [ "i2c" ];
services.xserver.displayManager = {
# Put the login screen on the left monitor
lightdm.greeters.gtk.extraConfig = ''
active-monitor=0
'';
# Set up screen position and rotation
setupCommands = ''
${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \
--mode 1920x1200 \
--pos 1920x0 \
--rotate left \
--output HDMI-0 \
--primary \
--mode 1920x1080 \
--pos 0x560 \
--rotate normal \
--output DVI-0 --off \
--output DVI-1 --off \
'';
};
};
} }

View File

@ -1,22 +1,21 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
config = config = lib.mkIf config.gui.enable {
lib.mkIf (config.gui.enable && config.physical && pkgs.stdenv.isLinux) {
# Mouse customization # Mouse customization
services.ratbagd.enable = true; services.ratbagd.enable = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
libratbag # Mouse adjustments libratbag # Mouse adjustments
piper # Mouse adjustments GUI piper # Mouse adjustments GUI
]; ];
services.xserver.libinput.mouse = {
# Disable mouse acceleration
accelProfile = "flat";
accelSpeed = "1.15";
};
services.xserver.libinput.mouse = {
# Disable mouse acceleration
accelProfile = "flat";
accelSpeed = "1.15";
}; };
};
} }

View File

@ -1,14 +1,10 @@
{ config, pkgs, lib, ... }: { { ... }: {
config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) { # The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# The global useDHCP flag is deprecated, therefore explicitly set to false here. # replicates the default behaviour.
# Per-interface useDHCP will be mandatory in the future, so this generated config networking.useDHCP = false;
# replicates the default behaviour. networking.interfaces.enp0s31f6.useDHCP = true;
networking.useDHCP = false; networking.interfaces.wlp3s0.useDHCP = true;
networking.interfaces.enp0s31f6.useDHCP = true;
networking.interfaces.wlp3s0.useDHCP = true;
};
} }

View File

@ -1,11 +0,0 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf (pkgs.stdenv.isLinux && config.server) {
# Servers need a bootloader or they won't start
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
};
}

View File

@ -1,12 +1,8 @@
{ config, pkgs, lib, ... }: { { ... }: {
config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) { # Prevent wake from keyboard
powerManagement.powerDownCommands = ''
# Prevent wake from keyboard for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done
powerManagement.powerDownCommands = '' '';
for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done
'';
};
} }

View File

@ -1,13 +1,9 @@
{ config, pkgs, lib, ... }: { { ... }: {
config = lib.mkIf (config.physical && config.isLinux) { # Enables wireless support via wpa_supplicant.
networking.wireless.enable = true;
# Enables wireless support via wpa_supplicant. # Allows the user to control the WiFi settings.
networking.wireless.enable = true; networking.wireless.userControlled.enable = true;
# Allows the user to control the WiFi settings.
networking.wireless.userControlled.enable = true;
};
} }

View File

@ -1,189 +0,0 @@
{ config, pkgs, lib, ... }: {
options.mail.aerc.enable = lib.mkEnableOption "Aerc email.";
config = lib.mkIf config.mail.aerc.enable {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
w3m # Render HTML
dante # Socksify for rendering HTML
];
programs.aerc = {
enable = true;
extraBinds = {
# Binds are of the form <key sequence> = <command to run>
# To use '=' in a key sequence, substitute it with "Eq": "<Ctrl+Eq>"
# If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit
global = {
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab <Enter>";
"<C-t>" = ":term<Enter>";
"?" = ":help keys<Enter>";
};
messages = {
q = ":quit<Enter>";
j = ":next <Enter>";
"<Down>" = ":next<Enter>";
"<C-d>" = ":next 50%<Enter>";
"<C-f>" = ":next 100%<Enter>";
"<PgDn>" = ":next 100%<Enter>";
k = ":prev <Enter>";
"<Up>" = ":prev<Enter>";
"<C-u>" = ":prev 50%<Enter>";
"<C-b>" = ":prev 100%<Enter>";
"<PgUp>" = ":prev 100%<Enter>";
g = ":select 0 <Enter>";
G = ":select -1<Enter>";
J = ":next-folder <Enter>";
K = ":prev-folder<Enter>";
H = ":collapse-folder<Enter>";
L = ":expand-folder<Enter>";
v = ":mark -t<Enter>";
V = ":mark -v<Enter>";
T = ":toggle-threads<Enter>";
"<Enter>" = ":view<Enter>";
d = ":prompt 'Really delete this message?' 'delete-message'<Enter>";
D = ":move Trash<Enter>";
A = ":archive flat<Enter>";
C = ":compose<Enter>";
rr = ":reply -a<Enter>";
rq = ":reply -aq<Enter>";
Rr = ":reply<Enter>";
Rq = ":reply -q<Enter>";
c = ":cf<space>";
"$" = ":term<space>";
"!" = ":term<space>";
"|" = ":pipe<space>";
"/" = ":search<space>";
"\\" = ":filter <space>";
n = ":next-result<Enter>";
N = ":prev-result<Enter>";
"<Esc>" = ":clear<Enter>";
};
"messages:folder=Drafts" = { "<Enter>" = ":recall<Enter>"; };
view = {
"/" = ":toggle-key-passthrough <Enter> /";
q = ":close<Enter>";
O = ":open<Enter>";
S = ":save<space>";
"|" = ":pipe<space>";
D = ":move Trash<Enter>";
A = ":archive flat<Enter>";
"<C-l>" = ":open-link <space>";
f = ":forward <Enter>";
rr = ":reply -a<Enter>";
rq = ":reply -aq<Enter>";
Rr = ":reply<Enter>";
Rq = ":reply -q<Enter>";
H = ":toggle-headers<Enter>";
"<C-k>" = ":prev-part<Enter>";
"<C-j>" = ":next-part<Enter>";
J = ":next <Enter>";
K = ":prev<Enter>";
};
"view::passthrough" = {
"$noinherit" = "true";
"$ex" = "<C-x>";
"<Esc>" = ":toggle-key-passthrough<Enter>";
};
compose = {
# Keybindings used when the embedded terminal is not selected in the compose
# view
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-k>" = ":prev-field<Enter>";
"<C-j>" = ":next-field<Enter>";
"<A-p>" = ":switch-account -p<Enter>";
"<A-n>" = ":switch-account -n<Enter>";
"<tab>" = ":next-field<Enter>";
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab<Enter>";
};
"compose::editor" = {
# Keybindings used when the embedded terminal is selected in the compose view
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-k>" = ":prev-field<Enter>";
"<C-j>" = ":next-field<Enter>";
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab<Enter>";
};
"compose::review" = {
# Keybindings used when reviewing a message to be sent
y = ":send <Enter>";
n = ":abort<Enter>";
p = ":postpone<Enter>";
q = ":choose -o d discard abort -o p postpone postpone<Enter>";
e = ":edit<Enter>";
a = ":attach<space>";
d = ":detach<space>";
};
terminal = {
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab<Enter>";
};
};
extraConfig = {
general.unsafe-accounts-conf = true;
viewer = { pager = "${pkgs.less}/bin/less -R"; };
filters = {
"text/plain" =
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize";
"text/calendar" =
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/calendar";
"text/html" =
"${pkgs.aerc}/share/aerc/filters/html"; # Requires w3m, dante
# "text/html" =
# "${pkgs.aerc}/share/aerc/filters/html | ${pkgs.aerc}/share/aerc/filters/colorize";
# "text/*" =
# ''${pkgs.bat}/bin/bat -fP --file-name="$AERC_FILENAME "'';
"message/delivery-status" =
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize";
"message/rfc822" =
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize";
"application/x-sh" = "${pkgs.bat}/bin/bat -fP -l sh";
"application/pdf" = "${pkgs.zathura}/bin/zathura -";
};
};
};
accounts.email.accounts.home.aerc = {
enable = true;
extraAccounts = {
check-mail = "5m";
check-mail-cmd = "${pkgs.isync}/bin/mbsync -a";
};
};
programs.fish.shellAbbrs = { ae = "aerc"; };
};
};
}

View File

@ -1,83 +0,0 @@
{ config, pkgs, lib, ... }: {
imports = [ ./himalaya.nix ./aerc.nix ];
options = {
mail.user = lib.mkOption {
type = lib.types.str;
description = "User name for the email address.";
default = config.user;
};
mail.server = lib.mkOption {
type = lib.types.str;
description = "Server name for the email address.";
};
};
config = lib.mkIf (config.mail.user != null && config.mail.server != null) {
home-manager.users.${config.user} = {
programs.mbsync = { enable = true; };
services.mbsync = lib.mkIf pkgs.stdenv.isLinux {
enable = true;
frequency = "*:0/5";
};
accounts.email = {
maildirBasePath = "${config.homePath}/mail";
accounts = {
home = let address = "${config.mail.user}@${config.mail.server}";
in {
userName = address;
realName = config.fullName;
primary = true;
inherit address;
aliases = map (user: "${user}@${config.mail.server}") [
"me"
"hey"
"admin"
];
alot = { };
flavor = "plain";
folders = { };
getmail = { };
imap = {
host = "imap.purelymail.com";
port = 993;
tls.enable = true;
};
imapnotify = {
enable = false;
boxes = [ ];
onNotify = "";
onNotifyPost = "";
};
maildir = { path = "main"; };
mbsync = {
enable = true;
create = "maildir";
expunge = "none";
remove = "none";
patterns = [ "*" ];
extraConfig.channel = {
CopyArrivalDate = "yes"; # Sync time of original message
};
};
mu.enable = false;
notmuch.enable = false;
passwordCommand =
"${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${
builtins.toString ../../private/mailpass.age
}";
smtp = {
host = "smtp.purelymail.com";
port = 465;
tls.enable = true;
};
};
};
};
};
};
}

View File

@ -1,19 +1,87 @@
{ config, lib, ... }: { { config, pkgs, lib, ... }: {
options.mail.himalaya.enable = lib.mkEnableOption "Himalaya email."; options = {
mailUser = lib.mkOption {
type = lib.types.str;
description = "User name for the email address.";
default = config.user;
};
mailServer = lib.mkOption {
type = lib.types.str;
description = "Server name for the email address.";
};
};
config = lib.mkIf config.mail.himalaya.enable { config = {
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
programs.himalaya = { enable = true; }; programs.himalaya = { enable = true; };
accounts.email.accounts.home.himalaya = { programs.mbsync = { enable = true; };
services.mbsync = lib.mkIf pkgs.stdenv.isLinux {
enable = true; enable = true;
backend = "imap"; frequency = "*:0/5";
sender = "smtp"; };
settings = {
downloads-dir = config.userDirs.download; accounts.email = {
smtp-insecure = true; maildirBasePath = "${config.homePath}/mail";
accounts = {
home = let address = "${config.mailUser}@${config.mailServer}";
in {
userName = address;
realName = config.fullName;
primary = true;
inherit address;
aliases = map (mailUser: "${mailUser}@${config.mailServer}") [
"me"
"hey"
"admin"
];
alot = { };
flavor = "plain";
folders = { };
getmail = { };
himalaya = {
enable = true;
settings = {
downloads-dir = config.userDirs.download;
smtp-insecure = true;
};
};
imap = {
host = "imap.purelymail.com";
port = 993;
tls.enable = true;
};
imapnotify = {
enable = false;
boxes = [ ];
onNotify = "";
onNotifyPost = "";
};
maildir = { path = "main"; };
mbsync = {
enable = true;
create = "maildir";
expunge = "none";
remove = "none";
patterns = [ "*" ];
extraConfig.channel = {
CopyArrivalDate = "yes"; # Sync time of original message
};
};
mu.enable = false;
notmuch.enable = false;
passwordCommand =
"${pkgs.age}/bin/age --decrypt --identity ${config.homePath}/.ssh/id_ed25519 ${
builtins.toString ./mailpass.age
}";
smtp = {
host = "smtp.purelymail.com";
port = 465;
tls.enable = true;
};
};
}; };
}; };

View File

@ -0,0 +1,5 @@
age-encryption.org/v1
-> ssh-ed25519 MgHaOw 8h/ESNjn0gknNXoHM34UobHzPgmRunoP97H+KHOuGQM
qowH+6TlCRECGCscRgKx6kswY+PZezYUD6E+x9e+5pM
--- kFj1JzRdh/D13Uq9aNTzMJIFysEE+kzzthjewOIR2+o
Ȳ<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD><EFBFBD>}rC<72>z<><7A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>

View File

@ -1,22 +0,0 @@
{ pkgs, ... }: {
plugins = [
pkgs.vimPlugins.bufferline-nvim
pkgs.vimPlugins.vim-bbye # Better closing of buffers
];
setup.bufferline = {
options = {
diagnostics = "nvim_lsp";
always_show_bufferline = false;
separator_style = "slant";
offsets = [{ filetype = "NvimTree"; }];
};
};
lua = ''
-- Move buffers
vim.keymap.set("n", "L", ":BufferLineCycleNext<CR>", { silent = true })
vim.keymap.set("n", "H", ":BufferLineCyclePrev<CR>", { silent = true })
-- Kill buffer
vim.keymap.set("n", "<Leader>x", " :Bdelete<CR>", { silent = true })
'';
}

View File

@ -1,155 +0,0 @@
{ pkgs, dsl, ... }: {
plugins = [
pkgs.vimPlugins.cmp-nvim-lsp
pkgs.vimPlugins.cmp-buffer
pkgs.vimPlugins.cmp-path
pkgs.vimPlugins.cmp-cmdline
pkgs.vimPlugins.cmp-nvim-lua
pkgs.vimPlugins.luasnip
pkgs.vimPlugins.cmp_luasnip
pkgs.vimPlugins.cmp-rg
pkgs.vimPlugins.friendly-snippets
];
use.cmp.setup = dsl.callWith {
# Disable in telescope buffers
enabled = dsl.rawLua ''
function()
if vim.bo.buftype == "prompt" then
return false
end
return true
end
'';
snippet.expand = dsl.rawLua ''
function(args)
require("luasnip").lsp_expand(args.body)
end
'';
mapping = {
"['<C-n>']" = dsl.rawLua
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Insert })";
"['<C-p>']" = dsl.rawLua
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Insert })";
"['<Down>']" = dsl.rawLua
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Select })";
"['<Up>']" = dsl.rawLua
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Select })";
"['<C-d>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(-4)";
"['<C-f>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(4)";
"['<C-e>']" = dsl.rawLua "require('cmp').mapping.abort()";
"['<CR>']" = dsl.rawLua
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
"['<C-r>']" = dsl.rawLua
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
"['<Esc>']" = dsl.rawLua ''
function(_)
cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
})
vim.cmd("stopinsert") --- Abort and leave insert mode
end
'';
"['<C-l>']" = dsl.rawLua ''
cmp.mapping(function(_)
if require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
end
end, { "i", "s" })
'';
};
sources = [
{ name = "nvim_lua"; }
{ name = "nvim_lsp"; }
{ name = "luasnip"; }
{ name = "path"; }
{
name = "buffer";
keyword_length = 3;
max_item_count = 10;
}
{
name = "rg";
keyword_length = 6;
max_item_count = 10;
option = { additional_arguments = "--ignore-case"; };
}
];
formatting = {
fields = [ "kind" "abbr" "menu" ];
format = dsl.rawLua ''
function(entry, vim_item)
local kind_icons = {
Text = "",
Method = "m",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
vim_item.menu = ({
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
rg = "[Grep]",
nvim_lsp = "[LSP]",
nvim_lua = "[Lua]",
})[entry.source.name]
return vim_item
end
'';
};
experimental = {
native_menu = false; # Use cmp menu instead of Vim menu
ghost_text = true; # Show preview auto-completion
};
};
lua = ''
-- Use buffer source for `/`
require('cmp').setup.cmdline("/", {
sources = {
{ name = "buffer", keyword_length = 5 },
},
})
-- Use cmdline & path source for ':'
require('cmp').setup.cmdline(":", {
sources = require('cmp').config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
})
'';
}

View File

@ -1,35 +0,0 @@
vim.keymap.set("", "<Space>", "<Nop>", { silent = true })
vim.g.mapleader = " "
vim.g.maplocalleader = " "
local gitsigns = require("gitsigns")
vim.keymap.set("n", "<Leader>gB", gitsigns.blame_line)
vim.keymap.set("n", "<Leader>gp", gitsigns.preview_hunk)
vim.keymap.set("v", "<Leader>gp", gitsigns.preview_hunk)
vim.keymap.set("n", "<Leader>gd", gitsigns.diffthis)
vim.keymap.set("v", "<Leader>gd", gitsigns.diffthis)
vim.keymap.set("n", "<Leader>rgf", gitsigns.reset_buffer)
vim.keymap.set("v", "<Leader>hs", gitsigns.stage_hunk)
vim.keymap.set("n", "<Leader>hr", gitsigns.reset_hunk)
vim.keymap.set("v", "<Leader>hr", gitsigns.reset_hunk)
-- Navigation
vim.keymap.set("n", "]g", function()
if vim.wo.diff then
return "]g"
end
vim.schedule(function()
gitsigns.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
vim.keymap.set("n", "[g", function()
if vim.wo.diff then
return "[g"
end
vim.schedule(function()
gitsigns.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })

View File

@ -1,5 +0,0 @@
{ pkgs, ... }: {
plugins = [ pkgs.vimPlugins.gitsigns-nvim ];
setup.gitsigns = { };
lua = builtins.readFile ./gitsigns.lua;
}

View File

@ -1,10 +0,0 @@
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation)
vim.keymap.set("n", "gh", vim.lsp.buf.hover)
-- vim.keymap.set("n", "gr", telescope.lsp_references)
vim.keymap.set("n", "<Leader>R", vim.lsp.buf.rename)
vim.keymap.set("n", "]e", vim.diagnostic.goto_next)
vim.keymap.set("n", "[e", vim.diagnostic.goto_prev)
vim.keymap.set("n", "<Leader>de", vim.diagnostic.open_float)
vim.keymap.set("n", "<Leader>E", vim.lsp.buf.code_action)

View File

@ -1,63 +0,0 @@
{ pkgs, dsl, ... }: {
plugins = [
pkgs.vimPlugins.nvim-lspconfig
pkgs.vimPlugins.lsp-colors-nvim
pkgs.vimPlugins.null-ls-nvim
];
use.lspconfig.sumneko_lua.setup = dsl.callWith {
settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; };
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
cmd = [ "${pkgs.sumneko-lua-language-server}/bin/lua-language-server" ];
};
use.lspconfig.nil_ls.setup = dsl.callWith {
cmd = [ "${pkgs.nil}/bin/nil" ];
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
};
use.lspconfig.pyright.setup = dsl.callWith {
cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ];
};
use.lspconfig.terraformls.setup =
dsl.callWith { cmd = [ "${pkgs.terraform-ls}/bin/terraform-ls" "serve" ]; };
vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ];
lua = ''
${builtins.readFile ./lsp.lua}
require("null-ls").setup({
sources = {
require("null-ls").builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }),
require("null-ls").builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }),
require("null-ls").builtins.diagnostics.flake8.with({ command = "${pkgs.python310Packages.flake8}/bin/flake8" }),
require("null-ls").builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }),
require("null-ls").builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }),
require("null-ls").builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }),
require("null-ls").builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }),
require("null-ls").builtins.formatting.shfmt.with({
command = "${pkgs.shfmt}/bin/shfmt",
extra_args = { "-i", "4", "-ci" },
}),
require("null-ls").builtins.formatting.terraform_fmt.with({ command = "${pkgs.terraform}/bin/terraform" }),
},
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
end,
})
'';
}

View File

@ -1,70 +0,0 @@
{ pkgs, dsl, lib, ... }: {
plugins = [
pkgs.vimPlugins.vim-surround # Keybinds for surround characters
pkgs.vimPlugins.vim-eunuch # File manipulation commands
pkgs.vimPlugins.vim-fugitive # Git commands
pkgs.vimPlugins.vim-repeat # Better repeat using .
pkgs.vimPlugins.comment-nvim # Smart comment commands
pkgs.vimPlugins.impatient-nvim # Faster load times
pkgs.vimPlugins.glow-nvim # Markdown preview popup
pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews
];
setup.Comment = { };
setup.colorizer = { };
vim.o = {
termguicolors = true; # Set to truecolor
hidden = true; # Don't unload buffers when leaving them
list = true; # Reveal whitespace with dashes
expandtab = true; # Tabs into spaces
shiftwidth = 4; # Amount to shift with > key
softtabstop = 4; # Amount to shift with <TAB> key
ignorecase = true; # Ignore case when searching
smartcase = true; # Check case when using capitals in search
infercase = true; # Don't match cases when completing suggestions
incsearch = true; # Search while typing
visualbell = true; # No sounds
scrolljump = 1; # Number of lines to scroll
scrolloff = 3; # Margin of lines to see while scrolling
splitright = true; # Vertical splits on the right side
splitbelow = true; # Horizontal splits on the bottom side
pastetoggle = "<F3>"; # Use F3 to enter raw paste mode
clipboard = "unnamedplus"; # Uses system clipboard for yanking
updatetime = 300; # Faster diagnostics
mouse = "nv"; # Mouse interaction / scrolling
inccommand = "split"; # Live preview search and replace
};
vim.wo = {
number = true; # Show line numbers
relativenumber = true; # Relative numbers instead of absolute
};
# Better backup, swap and undo storage
vim.o.backup = true; # Easier to recover and more secure
vim.bo.swapfile = false; # Instead of swaps, create backups
vim.bo.undofile = true; # Keeps undos after quit
vim.o.backupdir = dsl.rawLua ''vim.fn.stdpath("cache") .. "/backup"'';
# Required for nvim-cmp completion
vim.opt.completeopt = [ "menu" "menuone" "noselect" ];
lua = lib.mkBefore ''
require("impatient")
${builtins.readFile ../lua/keybinds.lua};
${builtins.readFile ../lua/settings.lua};
'';
vimscript = ''
" Remember last position when reopening file
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" LaTeX options
au FileType tex inoremap ;bf \textbf{}<Esc>i
au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
" Flash highlight when yanking
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 }
'';
}

View File

@ -1,9 +0,0 @@
{ pkgs, ... }: {
plugins = [ pkgs.vimPlugins.lualine-nvim ];
setup.lualine = {
options = {
theme = "gruvbox";
icons_enabled = true;
};
};
}

View File

@ -1,52 +0,0 @@
{ pkgs, ... }: {
plugins = [
(pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins:
with pkgs.tree-sitter-grammars; [
tree-sitter-hcl
tree-sitter-python
tree-sitter-lua
tree-sitter-nix
tree-sitter-fish
tree-sitter-toml
tree-sitter-yaml
tree-sitter-json
]))
pkgs.vimPlugins.vim-matchup # Better % jumping in languages
pkgs.vimPlugins.nginx-vim
pkgs.vimPlugins.vim-helm
pkgs.vimPlugins.vim-puppet
];
setup."nvim-treesitter.configs" = {
highlight = { enable = true; };
indent = { enable = true; };
textobjects = {
select = {
enable = true;
lookahead = true; # Jump forward automatically
keymaps = {
"['af']" = "@function.outer";
"['if']" = "@function.inner";
"['ac']" = "@class.outer";
"['ic']" = "@class.inner";
"['al']" = "@loop.outer";
"['il']" = "@loop.inner";
"['aa']" = "@call.outer";
"['ia']" = "@call.inner";
"['ar']" = "@parameter.outer";
"['ir']" = "@parameter.inner";
"['aC']" = "@comment.outer";
"['iC']" = "@comment.outer";
"['a/']" = "@comment.outer";
"['i/']" = "@comment.outer";
"['a;']" = "@statement.outer";
"['i;']" = "@statement.outer";
};
};
};
};
}

View File

@ -1,69 +0,0 @@
local telescope = require("telescope.builtin")
vim.keymap.set("n", "<Leader>k", telescope.keymaps)
vim.keymap.set("n", "<Leader>/", telescope.live_grep)
vim.keymap.set("n", "<Leader>ff", telescope.find_files)
vim.keymap.set("n", "<Leader>fp", telescope.git_files)
vim.keymap.set("n", "<Leader>fw", telescope.grep_string)
vim.keymap.set("n", "<Leader>b", telescope.buffers)
vim.keymap.set("n", "<Leader>hh", telescope.help_tags)
vim.keymap.set("n", "<Leader>fr", telescope.oldfiles)
vim.keymap.set("n", "<Leader>cc", telescope.commands)
vim.keymap.set("n", "<Leader>gc", telescope.git_commits)
vim.keymap.set("n", "<Leader>gf", telescope.git_bcommits)
vim.keymap.set("n", "<Leader>gb", telescope.git_branches)
vim.keymap.set("n", "<Leader>gs", telescope.git_status)
vim.keymap.set("n", "<Leader>s", telescope.current_buffer_fuzzy_find)
vim.keymap.set("n", "<Leader>N", function()
local opts = {
prompt_title = "Search Notes",
cwd = "$NOTES_PATH",
}
telescope.live_grep(opts)
end)
vim.keymap.set("n", "<Leader>fN", function()
local opts = {
prompt_title = "Find Notes",
cwd = "$NOTES_PATH",
}
telescope.find_files(opts)
end)
vim.keymap.set("n", "<Leader>cr", function()
local opts = require("telescope.themes").get_ivy({
layout_config = {
bottom_pane = {
height = 15,
},
},
})
telescope.command_history(opts)
end)
-- Zoxide
vim.keymap.set("n", "<Leader>fz", require("telescope").extensions.zoxide.list)
-- Project
require("telescope").load_extension("project")
vim.keymap.set("n", "<C-p>", function()
local opts = require("telescope.themes").get_ivy({
layout_config = {
bottom_pane = {
height = 10,
},
},
})
require("telescope").extensions.project.project(opts)
end)
-- File browser
require("telescope").load_extension("file_browser")
vim.keymap.set("n", "<Leader>fa", require("telescope").extensions.file_browser.file_browser)
vim.keymap.set("n", "<Leader>fD", function()
local opts = {
prompt_title = "Find Downloads",
cwd = "~/downloads",
}
require("telescope").extensions.file_browser.file_browser(opts)
end)

View File

@ -1,34 +0,0 @@
{ pkgs, dsl, ... }: {
plugins = [
pkgs.vimPlugins.telescope-nvim
pkgs.vimPlugins.telescope-project-nvim
pkgs.vimPlugins.telescope-fzy-native-nvim
pkgs.vimPlugins.telescope-file-browser-nvim
pkgs.vimPlugins.telescope-zoxide
];
setup.telescope = {
defaults = {
mappings = {
i = {
"['<esc>']" = dsl.rawLua "require('telescope.actions').close";
"['<C-h>']" = "which_key";
};
};
};
pickers = {
find_files = { theme = "ivy"; };
oldfiles = { theme = "ivy"; };
buffers = { theme = "dropdown"; };
};
extensions = {
fzy_native = { };
zoxide = { };
project = { base_dirs = [ "~/dev" ]; };
};
};
lua = builtins.readFile ./telescope.lua;
}

View File

@ -1,40 +0,0 @@
vim.keymap.set("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode
-- Only set these keymaps for toggleterm
vim.api.nvim_create_autocmd("TermOpen", {
pattern = "term://*toggleterm#*",
callback = function()
-- vim.keymap.set("t", "<Esc>", "<C-\\><C-n>") --- Exit terminal mode
vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h")
vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j")
vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k")
vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>l")
end,
})
local terminal = require("toggleterm.terminal").Terminal
local basicterminal = terminal:new()
function TERM_TOGGLE()
basicterminal:toggle()
end
local nixpkgs = terminal:new({ cmd = "nix repl '<nixpkgs>'" })
function NIXPKGS_TOGGLE()
nixpkgs:toggle()
end
local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" })
function GITWATCH_TOGGLE()
gitwatch:toggle()
end
local k9s = terminal:new({ cmd = "k9s" })
function K9S_TOGGLE()
k9s:toggle()
end
vim.keymap.set("n", "<Leader>t", TERM_TOGGLE)
vim.keymap.set("n", "<Leader>P", NIXPKGS_TOGGLE)
vim.keymap.set("n", "<Leader>gw", GITWATCH_TOGGLE)
vim.keymap.set("n", "<Leader>9", K9S_TOGGLE)

View File

@ -1,13 +0,0 @@
{ pkgs, dsl, ... }: {
plugins = [ pkgs.vimPlugins.toggleterm-nvim ];
use.toggleterm.setup = dsl.callWith {
open_mapping = dsl.rawLua "[[<c-\\>]]";
hide_numbers = true;
direction = "float";
};
lua = builtins.readFile ./toggleterm.lua;
}

View File

@ -1,77 +0,0 @@
{ pkgs, dsl, ... }: {
plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ];
# Disable netrw eagerly
# https://github.com/kyazdani42/nvim-tree.lua/commit/fb8735e96cecf004fbefb086ce85371d003c5129
vim.g = {
loaded = 1;
loaded_netrwPlugin = 1;
};
setup.nvim-tree = {
disable_netrw = true;
hijack_netrw = true;
update_focused_file = {
enable = true;
update_cwd = true;
ignore_list = { };
};
diagnostics = {
enable = true;
icons = {
hint = "";
info = "";
warning = "";
error = "";
};
};
renderer = {
icons = {
glyphs = {
git = {
unstaged = "~";
staged = "+";
unmerged = "";
renamed = "";
deleted = "";
untracked = "?";
ignored = "";
};
};
};
};
view = {
width = 30;
hide_root_folder = false;
side = "left";
mappings = {
custom_only = false;
list = [
{
key = [ "l" "<CR>" "o" ];
cb = dsl.rawLua
"require('nvim-tree.config').nvim_tree_callback('edit')";
}
{
key = "h";
cb = dsl.rawLua
"require('nvim-tree.config').nvim_tree_callback('close_node')";
}
{
key = "v";
cb = dsl.rawLua
"require('nvim-tree.config').nvim_tree_callback('vsplit')";
}
];
};
number = false;
relativenumber = false;
};
};
lua = ''
vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>", { silent = true })
'';
}

View File

@ -1,44 +1,47 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }: {
let home-manager.users.${config.user} = {
neovim = import ./package { home.packages = with pkgs; [
inherit pkgs; neovim
colors = import config.theme.colors.neovimConfig { inherit pkgs; }; gcc # for tree-sitter
}; shfmt # used everywhere
shellcheck # used everywhere
in { ];
options.neovim.enable = lib.mkEnableOption "Neovim.";
config = lib.mkIf config.neovim.enable {
home-manager.users.${config.user} =
{
home.packages = [ neovim ];
programs.git.extraConfig.core.editor = "nvim";
home.sessionVariables = {
EDITOR = "nvim";
MANPAGER = "nvim +Man!";
};
programs.fish = {
shellAliases = { vim = "nvim"; };
shellAbbrs = {
v = lib.mkForce "nvim";
vl = lib.mkForce "nvim -c 'normal! `0' -c 'bdelete 1'";
vll = "nvim -c 'Telescope oldfiles'";
};
};
programs.kitty.settings.scrollback_pager = lib.mkForce ''
${neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -'';
xdg.configFile = {
"nvim/init.lua".source = ./init.lua;
"nvim/lua" = {
source = ./lua;
recursive = true; # Allows adding more files
}; };
"nvim/lua/packer/colors.lua".source = config.colorscheme.neovimConfig;
};
# # Used for icons in Vim programs.git.extraConfig.core.editor = "nvim";
# fonts.fonts = with pkgs; [ nerdfonts ]; home.sessionVariables = {
EDITOR = "nvim";
MANPAGER = "nvim +Man!";
};
programs.fish = {
shellAliases = { vim = "nvim"; };
shellAbbrs = {
v = lib.mkForce "nvim";
vl = lib.mkForce "vim -c 'normal! `0' -c 'bdelete 1'";
vll = "nvim -c 'Telescope oldfiles'";
};
};
# Always run packer.nvim sync
home.activation.nvimPackerSync =
config.home-manager.users.${config.user}.lib.dag.entryAfter
[ "writeBoundary" ] ''
$DRY_RUN_CMD ${pkgs.neovim}/bin/nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
'';
}; };
# Used for icons in Vim
fonts.fonts = with pkgs; [ nerdfonts ];
} }

View File

@ -1,4 +1,3 @@
require("packer_init") require("packer_init")
require("settings") require("settings")
require("keybinds") require("keybinds")
require("background")

Some files were not shown because too many files have changed in this diff Show More