Compare commits

..

54 commits

Author SHA1 Message Date
b8257363d3 Tweaks
- Add `pw` wrapper that uses `sk` to make it easier to get passwords
- Enable spellcheck in markdown files in kakoune
2022-09-13 13:38:25 +02:00
ffd48fa9ea Add sc script 2022-09-05 10:05:34 +02:00
332bc9ca76 Update editor color scheme 2022-07-25 22:01:42 +02:00
d7e64ff1d6 Replace riley namespace with custom namespace 2022-07-25 13:31:15 +02:00
071577b83d Fix editor colors a bit 2022-07-25 13:31:15 +02:00
d066e930a4 fixup! Add clojure support to editor 2022-06-22 16:53:20 +02:00
afc03fe0cf Add clojure support to editor 2022-06-22 16:51:02 +02:00
3bdb545681 Improve sif -> thor dist build ssh config 2022-05-28 19:01:08 +02:00
0a946e4b70 Add steam 2022-05-28 18:39:33 +02:00
5919f10719 Make it work 2022-05-28 18:38:31 +02:00
02989b844d fixup! fixup! YEET 2022-05-27 16:18:02 +02:00
e6a9c3b503 fixup! YEET 2022-05-27 16:13:56 +02:00
c08a99f4a4 YEET 2022-05-27 16:10:51 +02:00
1410b20e7d Pls work lmao 2022-05-27 15:59:00 +02:00
76119aef0f Add support for remote builds 2022-05-27 13:39:05 +02:00
db168ad3a4 Sif config, remote website build, agenix for secrets 2022-05-27 13:34:37 +02:00
16d45d2bc2 Remove bootloader settings from modules/default.nix and moved to machine-specific configs 2022-05-23 20:58:06 +02:00
2b4aa8fd66 Add more Features to sif 2022-05-23 20:44:35 +02:00
0782b0cdba Update flake to work with sif 2022-05-23 18:15:03 +00:00
78b2cc7988 Add sif 2022-05-23 17:51:47 +00:00
81099d2644 Fix statusbar.nix 2022-05-23 14:06:03 +02:00
feff5a9f1b Add statusbar.nix 2022-05-23 14:04:21 +02:00
64dbffb53f fixup! fixup! Set indentwidth 2022-05-23 13:55:47 +02:00
8c3be332ab fixup! Set indentwidth 2022-05-23 13:41:26 +02:00
49e6949a20 Set indentwidth 2022-05-23 13:33:25 +02:00
c7110cee03 Fix kakoune 2022-05-23 13:28:54 +02:00
11e08fc437 Retab kak config 2022-05-23 13:17:26 +02:00
f398775552 Add oxalica overlay 2022-05-23 12:35:37 +02:00
b706942195 Add overlay to systemwide nixpkgs 2022-05-23 10:50:43 +02:00
60cd61444e Retab 2022-05-23 10:40:50 +02:00
8415b856a9 Remove symbolic link 2022-05-23 10:26:58 +02:00
ae41b3ae55 Remove old config 2022-05-23 10:22:08 +02:00
5247a535b1 Reformat 2022-05-23 10:16:05 +02:00
a59a56da09 fixup! Separate utils into a separate file 2022-05-19 20:14:25 +02:00
91473a3972 Separate utils into a separate file 2022-05-19 20:13:00 +02:00
d0e49183a0 IDE mode letsgoo 2022-05-19 19:58:26 +02:00
55a7cb8b00 Meow III 2022-05-16 17:59:44 +02:00
a646e3e016 Meow 2022-05-16 17:57:58 +02:00
b313f64189 Meow 2022-05-16 17:44:49 +02:00
8af394d0bd Start refactor of kakoune config 2022-05-15 23:32:21 +02:00
fc7ff7f450 Change terminal from alacritty to kitty 2022-05-15 21:01:45 +02:00
a66aaef42e Add overlays/ directory, remove forks/ 2022-05-15 20:26:40 +02:00
2e7f2257d4 Add readme 2022-05-15 20:23:34 +02:00
c911037516 Add table describing script files 2022-05-15 20:09:03 +02:00
953383d576 Fix utility scripts 2022-05-15 20:02:26 +02:00
030e457600 aa 2022-05-15 18:35:31 +02:00
a1a09c4b17 mORE FLAKES SHIT 2022-05-15 17:52:56 +02:00
7c75d415ff More flakes stuff 2022-05-15 17:31:45 +02:00
d427da7804 add flake lock 2022-05-15 16:57:06 +02:00
1f66bc0a71 add flake.nix 2022-05-15 16:56:03 +02:00
d2cc84899a uh idk lmao 2022-05-15 16:11:41 +02:00
048d5e012f uhhhh 2022-03-08 06:56:23 +01:00
cff0a2cf5b [kak]: Split some of the config into a separate file 2022-01-23 17:22:34 +01:00
9b49e2eefa [modules]: Moved some options to the files where they belong 2022-01-23 17:03:10 +01:00
49 changed files with 1717 additions and 831 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
configuration.nix

21
README.md Normal file
View file

@ -0,0 +1,21 @@
# NixOS config
NixOS configurations for a number of my machines.
I use home-manager to manage my dotfiles.
## Layout
`machines/` has a folder for each machine (identified by hostname) with its
`configuration.nix` and `hardware-configuration.nix`. Modules specific to each machine
also go in their respective directories.
Config values that are common to all my machines are in `common.nix`.
`scripts/` contains shell scripts and small, trivial utilities that are intended to be
invoked on the command line.
`modules/` contains NixOS modules that configure things like git, ssh, my window manager
and my editor.
`overlays/` contains nix overlays.

View file

@ -57,12 +57,12 @@ let inherit (builtins) mapAttrs map; in rec {
red = {
normal = "ff6161";
bright = "ff3b3b";
pastel = "ff5369";
pastel = "ff7588";
};
green = {
bright = "29f26c";
normal = "8aff80";
bright = "29f26c";
pastel = "";
};
@ -75,29 +75,29 @@ let inherit (builtins) mapAttrs map; in rec {
yellow = {
normal = "fcfc51";
bright = "fcfc51";
pastel = "";
pastel = "e9ff87";
};
purple = {
normal = "bd78fa";
normal = "b58aff";
bright = "c97ffa";
pastel = "00e1ff";
pastel = "d9b5ff";
};
cyan = {
normal = "29f8ff";
bright = "26e3fc";
pastel = "";
pastel = "63e8ff";
};
pink = {
normal = "f74ddb";
normal = "ee8fff";
bright = "ff63e5";
pastel = "";
pastel = "ff96e3";
};
orange = {
normal = "ff5e69";
normal = "ff8c26";
bright = "fca151";
pastel = "";
};

38
common.nix Normal file
View file

@ -0,0 +1,38 @@
# Holds common settings for *all* systems, including both servers and
# clients.
{ pkgs, oxalica, ... }: {
nix = {
trustedUsers = [ "riley" ];
optimise.automatic = true;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
nixpkgs = {
config = { allowUnfree = true; };
overlays = [
# Import overlays defined under the `overlays/` directory.
(import ./overlays)
# Clients need Rust for development, servers need Rust for
# deployment.
oxalica.overlay
];
};
boot.cleanTmpDir = true;
environment.systemPackages = [
# Include common packages I use everywhere, like `rg`
# and `exa`
(import ./env.nix { inherit pkgs; })
];
}

View file

@ -1,87 +0,0 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{
config = {
imports = [
# Home-manager modules
<home-manager/nixos>
./hardware-configuration.nix
# Programs
./modules/kakoune
./alacritty.nix
./git.nix
# Display server and related config
./display.nix
./fonts.nix
];
nixpkgs.config.allowUnfree = true;
nix.autoOptimiseStore = true;
nix.gc.automatic = true;
boot = {
loader.systemd-boot = {
enable = true;
editor = false;
configurationLimit = 10;
};
loader.efi.canTouchEfiVariables = true;
cleanTmpDir = true;
};
networking.hostName = "thor";
# Set your time zone.
time.timeZone = "Europe/Amsterdam";
networking.useDHCP = false;
networking.interfaces.enp9s0.useDHCP = true;
sound.enable = true;
hardware.pulseaudio.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users."riley" = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
};
environment.systemPackages = with pkgs; [
# Some utils
wget
curl
git
# Modern coreutils
ripgrep
bottom
skim
exa
bat
lf
fd
];
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.11"; # Did you read the comment?
};
}

15
env.nix Normal file
View file

@ -0,0 +1,15 @@
# Packages I tend to use
{ pkgs }: pkgs.buildEnv {
name = "riley-user-utils";
paths = with pkgs; [
ripgrep
bottom
delta
skim
exa
bat
lf
fd
];
}

164
flake.lock Normal file
View file

@ -0,0 +1,164 @@
{
"nodes": {
"agenix": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1652712410,
"narHash": "sha256-hMJ2TqLt0DleEnQFGUHK9sV2aAzJPU8pZeiZoqRozbE=",
"owner": "ryantm",
"repo": "agenix",
"rev": "7e5e58b98c3dcbf497543ff6f22591552ebfe65b",
"type": "github"
},
"original": {
"owner": "ryantm",
"repo": "agenix",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1656065134,
"narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": "nixpkgs_2",
"utils": "utils"
},
"locked": {
"lastModified": 1658750091,
"narHash": "sha256-T7wmpoE5UJPuX8VQCpZIG7O8foAC3BCr+DK+GnXA4uM=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "8419dfd39d678afd5bc40df48f21fcaad8fc1332",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1638587357,
"narHash": "sha256-2ySMW3QARG8BsRPmwe7clTbdCuaObromOKewykP+UJc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e34c5379866833f41e2a36f309912fa675d687c7",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1654953433,
"narHash": "sha256-TwEeh4r50NdWHFAHQSyjCk2cZxgwUfcCCAJOhPdXB28=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "90cd5459a1fd707819b9a3fb9c852beaaac3b79a",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1658648081,
"narHash": "sha256-RL5nr4Xhp0zQeEGG/I3t3FmqaI9QrBg5PH31NF+7A/A=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e494a908e8895b9cba18e21d5fc83362f64b3f6a",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1656401090,
"narHash": "sha256-bUS2nfQsvTQW2z8SK7oEFSElbmoBahOPtbXPm0AL3I4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "16de63fcc54e88b9a106a603038dd5dd2feb21eb",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"oxalica": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1658717414,
"narHash": "sha256-M5piRQdqU680bWhkpyQH09zub75VxfRtuQmNJc+1mhc=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "f612ccd516e97a14e4a7b55c6c88826f575e6805",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"root": {
"inputs": {
"agenix": "agenix",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs_3",
"oxalica": "oxalica"
}
},
"utils": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

65
flake.nix Normal file
View file

@ -0,0 +1,65 @@
{
inputs = {
# Living on the edge
nixpkgs = {
url = github:NixOS/nixpkgs/nixos-unstable;
};
# Used for managing dotfiles
home-manager = {
url = github:nix-community/home-manager;
};
# Rust overlay, for Rust development
oxalica = {
url = github:oxalica/rust-overlay;
};
# For managing secrets
agenix = {
url = "github:ryantm/agenix";
};
};
outputs = args: with args.nixpkgs; {
nixosConfigurations = {
# Desktop client
"thor" = lib.nixosSystem {
system = "x86_64-linux";
modules = [
./machines/thor/configuration.nix
./common.nix
];
specialArgs = args;
};
# Dell XPS laptop client
"loki" = lib.nixosSystem {
system = "x86_64-linux";
modules = [
./machines/loki/configuration.nix
./common.nix
];
specialArgs = args;
};
# TODO: Pinebook Pro
# Raspberry Pi server
"sif" = lib.nixosSystem {
system = "aarch64-linux";
modules = [
./machines/sif/configuration.nix
./common.nix
];
specialArgs = args;
};
};
};
}

View file

@ -1,50 +0,0 @@
{
fetchFromGitHub, lib, stdenv, pkg-config, installShellFiles, libxcb,
xcbutilkeysyms, xcbutil, xcbutilwm, xcbutilxrm, libstartup_notification, libX11, pcre,
libev, yajl, xcb-util-cursor, perl, pango, perlPackages, libxkbcommon, xorgserver,
xvfb-run, asciidoc, xmlto, docbook_xml_dtd_45, docbook_xsl, findXMLCatalogs,
autoconf, autoreconfHook
}:
with stdenv; mkDerivation rec {
pname = "i3-gaps-rounded";
version = "4.16.1-non-git";
src = fetchFromGitHub {
owner = "resloved";
repo = "i3";
rev = "b521c18ca1bca1c16d3fd69214ad3972bffc9e42";
sha256 = "0w4akd7mkdm4xlv2ai2hyjn45f1qgzj5g6n09hrcns1zv4nffcch";
};
nativeBuildInputs = [
pkg-config
installShellFiles
perl
asciidoc
xmlto
docbook_xml_dtd_45
docbook_xsl
findXMLCatalogs
autoreconfHook
];
buildInputs = [
libxcb xcbutilkeysyms xcbutil xcbutilwm xcbutilxrm libxkbcommon
libstartup_notification libX11 pcre libev yajl xcb-util-cursor perl pango
perlPackages.AnyEventI3 perlPackages.X11XCB perlPackages.IPCRun
perlPackages.ExtUtilsPkgConfig perlPackages.InlineC
xorgserver xvfb-run
];
doCheck = false;
postPatch = ''
patchShebangs .
'';
buildPhase = ''
cd x86_64-pc-linux-gnu
make all
'';
}

View file

@ -8,7 +8,7 @@
riley = {
gui = true;
ide = true;
kak.ide = true;
};
networking = {
@ -16,6 +16,18 @@
interfaces.wlp6s0.useDHCP = true;
};
boot = {
loader.systemd-boot = {
enable = true;
editor = false;
configurationLimit = 10;
};
loader.efi = {
canTouchEfiVariables = true;
};
};
devices = {
audio = {

3
machines/sif/README.md Normal file
View file

@ -0,0 +1,3 @@
# Sif
Sif is the server that hosts my website. It's a Raspberry Pi 3.

View file

@ -0,0 +1,91 @@
{ config, pkgs, lib, agenix, ... }:
{
imports = [
agenix.nixosModule
../../modules
# Reverse proxy
./services/nginx.nix
# Website
./services/website.nix
];
networking.hostName = "sif";
boot.loader = {
grub.enable = false;
generic-extlinux-compatible.enable = true;
};
documentation.enable = false;
environment.systemPackages = with pkgs; [
git
vim
];
age.secrets."website".file = ../../secrets/website.age;
system.stateVersion = "21.11";
# Custom modules defined by myself.
custom = {
gui.enable = false;
kak = {
enable = true;
ide.nix = true;
};
net.interfaces = [
"eth0"
];
};
users.users."riley" = {
isNormalUser = true;
extraGroups = [ "wheel" ];
};
networking.interfaces.eth0.useDHCP = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
fileSystems."/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
};
nix = {
distributedBuilds = true;
buildMachines = [{
hostName = "thor";
sshUser = "riley";
sshKey = "/root/.ssh/id_ed25519";
systems = [
"x86_64-linux"
"aarch64-linux"
];
supportedFeatures = [
"nixos-test"
"benchmark"
"big-parallel"
"kvm"
];
}];
};
}

View file

@ -0,0 +1,66 @@
{ ... }:
let enableACME = false;
port = toString 3000;
in {
security.acme = {
acceptTerms = true;
defaults.email = "me@riley.lgbt";
};
services.nginx.enable = true;
services.nginx.virtualHosts = {
"192.168.2.22" = {
listen = [{
port = 80;
addr = "192.168.2.22";
}];
locations."/" = {
proxyPass = "http://localhost:${port}";
};
};
# Main domain that hosts my website
"riley.lgbt" = {
inherit enableACME;
listen = [{
port = if enableACME then 443 else 80;
addr = "77.169.117.112";
}];
locations."/" = {
proxyPass = "http://localhost:${port}";
extraConfig = ''
proxy_set_header Host $host;
proxy_buffering off;
'';
};
};
"rly.cx" = {
inherit enableACME;
listen = [{
port = if enableACME then 443 else 80;
addr = "77.169.117.112";
}];
locations."/" = {
proxyPass = "http://localhost:${port}";
extraConfig = ''
proxy_set_header Host $host;
proxy_buffering off;
'';
};
};
};
}

View file

@ -0,0 +1,38 @@
{ pkgs, lib, config, ... }:
let secret = config.age.secrets."website".path;
builder = pkgs.rustPlatform.buildRustPackage.override {
rustc = (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal)).overrideAttrs (old: {
meta.platforms = [
"x86_64-linux"
"aarch64-linux"
];
});
};
website = builder {
pname = "website";
version = "0.1.0";
cargoSha256 = "sha256-4v45QaZKyjifn2MGyuy+SovfFBWu55FYR9nWRWlaQOM=";
postInstall = ''
cp ./links.toml $out/links.toml
cp -r ./static/ $out/static/
'';
src = pkgs.fetchgit {
url = "https://im.badat.dev/riley/website.git";
rev = "refs/heads/mistress";
sha256 = "sha256-QONZR4zpgifEQByH3rtfkHQjwQVrjRy89RVvVLMciKs=";
};
};
in {
systemd.services."website" = {
enable = true;
description = "Run my website :)";
path = [ website ];
script = ''
cd ${website}
SITE_API_SECRET=$(cat ${secret}) ${website}/bin/website
'';
};
}

View file

@ -1,21 +1,67 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, agenix, ... }:
{
imports = [
agenix.nixosModule
./hardware-configuration.nix
../../modules
];
riley = {
ide = true;
gui = true;
custom = {
gui = {
enable = true;
theme = (import ../../colors.nix).dark;
};
kak = {
enable = true;
haskell = true;
rust = true;
nix = true;
};
};
system.stateVersion = "21.11";
networking = {
hostName = "thor";
interfaces.enp9s0.useDHCP = true;
};
boot = {
loader.systemd-boot = {
enable = true;
editor = false;
configurationLimit = 10;
};
loader.efi = {
canTouchEfiVariables = true;
};
};
home-manager.users.riley.home.stateVersion = "21.11";
users.users."riley".packages = with pkgs; [
minecraft
cockatrice
];
programs.steam = {
enable = true;
};
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
services.xserver.videoDrivers = [ "nvidia" ];
age.secrets."website-secret".file = ../../secrets/website.age;
devices = {
# Audio devices

View file

@ -12,6 +12,7 @@
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/f3cdd2ab-62ba-4d72-8a28-b3adc0ec3997";

View file

@ -1,8 +1,9 @@
# Global config
# Modules used by most systems.
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, home-manager, ... }:
with lib; with types;
let themeType =
let named = submodule {
options = {
normal = mkOption { type = str; };
@ -17,7 +18,7 @@ let named = submodule {
slight = mkOption { type = str; };
};
};
themeType = submodule {
in submodule {
options = {
foreground = mkOption { type = special; };
background = mkOption { type = special; };
@ -33,29 +34,12 @@ let named = submodule {
misc = mkOption { type = attrsOf str; };
hex = mkOption { type = themeType; };
};
}; in
{
};
in {
options.riley = with lib; {
ide = mkOption {
type = types.bool;
description = ''
Enable IDE-like plugins such as language servers for Rust, Haskell and
Nix in the editor, and configure accordingly. If disabled, the editor
will lack some features such as semantic highlighting.
'';
default = true;
};
gui = mkOption {
type = types.bool;
description = ''
Enable the display server and related graphical programs.
'';
default = true;
};
theme = mkOption {
type = themeType;
description = ''
@ -122,9 +106,9 @@ let named = submodule {
imports = [
<home-manager/nixos>
home-manager.nixosModule
./ide
./kak
./gui
./fonts.nix
@ -137,6 +121,11 @@ let named = submodule {
riley.theme = (import ../colors.nix)."dark";
time.timeZone = "Europe/Amsterdam";
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
environment.systemPackages = with pkgs; [
# Web utils
@ -145,38 +134,54 @@ let named = submodule {
curl
git
# Coreutils
ripgrep
bottom
skim
exa
bat
lf
fd
];
boot = {
loader.systemd-boot = {
enable = true;
editor = false;
configurationLimit = 10;
environment.shellAliases = {
# Born to VIM
":q" = "exit";
# Sike I use kakoune
":e" = "kak";
# Launch [T]erminal
"t" = "alacritty";
# [D]isown
"d" = "disown";
};
loader.efi = {
canTouchEfiVariables = true;
};
programs.bash.interactiveShellInit = ''
cleanTmpDir = true;
};
# [G]o to the directory. Create the directory if it does not exist
# yet, and if the directory contains a shell.nix file, source it.
g () {
[ -d "$1" ] || mkdir -p "$1";
cd "$1";
[ -e "shell.nix" ] && nix-shell;
}
# [M]ake a directory and immediately enter it.
m () { mkdir -p "$1" && cd "$1"; }
# [R]eplace the current process with the given one.
r () { $1 & disown; exit; }
# [J]ump to the directory by means of fuzzy search. If the fuzzy finder
# is aborted, the jump is also aborted.
j () { t=`sk` && cd $t; }
# Enter a temporary [d]irectory.
d () { cd "$(mktemp -d)"; }
'';
networking = {
firewall.enable = false;
useDHCP = false;
};
nixpkgs.config.allowUnfree = true;
security.rtkit.enable = true;
users.users."riley" = {

View file

@ -20,7 +20,7 @@
enable = true;
defaultFonts = {
monospace = [
"Fira Mono"
"Fira Code"
"Source Code Pro"
"Noto Color Emoji"
];

View file

@ -1,45 +0,0 @@
{ pkgs, lib, config, ... }:
(lib.mkIf (config.riley.gui) {
home-manager.users."riley" = {
programs.alacritty = {
enable = true;
settings = {
window.padding = { x = 8; y = 8; };
font = {
normal = { family = "Fira Code"; style = "Regular"; };
bold = { family = "Fira Code"; style = "Medium"; };
};
colors = with config.riley.theme.hex; {
primary = {
background = background.primary;
foreground = foreground.primary;
};
normal = {
red = red.normal;
green = green.normal;
blue = blue.normal;
magenta = purple.normal;
yellow = yellow.normal;
cyan = cyan.normal;
};
bright = {
red = red.bright;
green = green.bright;
blue = blue.bright;
magenta = purple.bright;
yellow = yellow.bright;
cyan = cyan.bright;
};
};
};
};
};
})

View file

@ -1,24 +1,20 @@
{ config, lib, pkgs, ... }:
# This is a simple module that does not define its own options.
# Rather, it just looks at the `custom.gui.enable` option to
# determine if it needs to add anything.
(lib.mkIf (config.riley.gui) {
{ pkgs, lib, config, ... }:
let gui = config.custom.gui;
scripts = (import ../../scripts/clip.nix {
inherit pkgs;
});
in lib.mkIf (gui.enable) {
# Add some shell scripts that abstract away the
# horrible reality that the clipboard is managed by
# the display server.
users.users."riley".packages = with pkgs; [
users.users."riley".packages = with scripts; [ c p ];
(writeShellApplication {
name = "copy";
runtimeInputs = [ xclip ];
text = "xclip -sel clip -i";
})
(writeShellApplication {
name = "paste";
runtimeInputs = [ xclip ];
text = "xclip -sel clip -o";
})
];
})
}

View file

@ -1,20 +1,48 @@
{ pkgs, config, lib, ... }:
{ pkgs, lib, config, ... }:
({
let gui = config.custom.gui;
# Clipboard wrapper scripts
clip = (import ../../scripts/clip.nix {
inherit pkgs;
});
in
with lib; {
imports = [
./window-manager.nix
./wm
./pulseaudio.nix
./clipboard.nix
./alacritty.nix
./statusbar.nix
./terminal.nix
./theme.nix
];
}) // (lib.mkIf (config.riley.gui) {
options.custom.gui = {
# Graphical applications
users.users."riley".packages = with pkgs; [
# Use a nested enable option, to allow extension of this option
# namespace later on.
enable = mkEnableOption "gui applications and window manager";
};
config = mkIf (gui.enable) {
# Import some applications I use on all my graphical systems
users.users."riley".packages = (with pkgs; [
# My browser
google-chrome
tdesktop
];
})
# Telegram client
tdesktop
]) ++ (with clip; [ c p ]); # Add clipboard scripts
};
}

View file

@ -1,10 +1,21 @@
{ lib, config, pkgs, ... }:
{ pkgs, lib, config, ... }:
let gui = config.custom.gui; in
with lib; {
# Define pulseaudio toggle under the `audio` option set.
options.custom.gui.audio.pulseaudio = mkEnableOption "PulseAudio sound server";
config = mkIf (gui.audio.pulseaudio) {
(lib.mkIf (config.riley.gui) {
sound.enable = true;
hardware.pulseaudio.enable = true;
users.users."riley".packages = with pkgs; [
pavucontrol
];
})
};
}

11
modules/gui/statusbar.nix Normal file
View file

@ -0,0 +1,11 @@
{ pkgs, config, lib, ... }:
(lib.mkIf (config.custom.gui.enable && false) {
home-manager.users."riley" = {
services.polybar = {
enable = true;
script = "polybar bar &";
config = {}; # TODO
};
};
})

48
modules/gui/terminal.nix Normal file
View file

@ -0,0 +1,48 @@
# Module that adds my terminal emulator of choice to my environment.
{ pkgs, lib, config, ... }:
let gui = config.custom.gui; in
with lib; mkIf (gui.enable) {
home-manager.users."riley".programs.kitty = {
# Use kitty because it supports cool ligatures and
# has nice scripting capabilities.
enable = true;
font = {
name = "Fira Code";
size = 11;
};
settings = with gui.theme.hex; {
bold_font = "Fira Code Medium";
background = background.primary;
foreground = foreground.primary;
color1 = red.normal;
color9 = red.bright;
color2 = green.normal;
color10 = green.bright;
color3 = yellow.normal;
color11 = yellow.bright;
color4 = blue.normal;
color12 = blue.bright;
color5 = purple.normal;
color13 = purple.bright;
color6 = cyan.normal;
color14 = cyan.bright;
};
};
}

58
modules/gui/theme.nix Normal file
View file

@ -0,0 +1,58 @@
# Defines the global color theme option.
{ lib, ... }:
with lib; with types;
# Define the type in a let binding to prevent too much rightward
# drift in the option configuration.
let themeType =
let # Named colors are colors like "red" or "black".
named = submodule {
options = {
normal = mkOption { type = str; };
bright = mkOption { type = str; };
pastel = mkOption { type = str; };
};
};
# Special colors are more abstract, for example
# "foreground".
special = submodule {
options = {
primary = mkOption { type = str; };
normal = mkOption { type = str; };
slight = mkOption { type = str; };
};
};
in submodule {
options = {
foreground = mkOption { type = special; };
background = mkOption { type = special; };
grayscales = mkOption { type = listOf str; };
red = mkOption { type = named; };
green = mkOption { type = named; };
blue = mkOption { type = named; };
yellow = mkOption { type = named; };
purple = mkOption { type = named; };
cyan = mkOption { type = named; };
pink = mkOption { type = named; };
orange = mkOption { type = named; };
misc = mkOption { type = attrsOf str; };
hex = mkOption { type = themeType; };
};
};
in {
options.custom.gui.theme = mkOption {
type = themeType;
description = ''
Color theme used across the installation for various
GUI elements and terminal colors.
'';
};
}

View file

@ -1,10 +1,12 @@
{ pkgs, config, lib, ... }:
let theme = config.riley.theme.hex;
let scripts = (import ./scripts.nix { inherit pkgs; });
theme = config.riley.theme.hex;
modifier = "Mod4";
terminal = "${pkgs.kitty}/bin/kitty";
keybindings = (import ./keybinds.nix {
inherit modifier lib pkgs config;
inherit modifier lib pkgs config scripts;
directional = {
left = "H";
@ -14,20 +16,24 @@ let theme = config.riley.theme.hex;
};
workspace = {
numbered = 5;
numbered = 6;
named = {
"web" = "equal";
"doc" = "minus";
"dev" = "0";
"chat" = "q";
"code" = "w";
"browser" = "e";
};
};
launchers = {
browser = "google-chrome-stable";
inherit terminal;
};
});
in (lib.mkIf (config.riley.gui) {
in
with lib; (mkIf config.custom.gui.enable {
services.xserver = {
enable = true;
windowManager.i3.enable = true;
@ -39,14 +45,12 @@ in (lib.mkIf (config.riley.gui) {
config = with lib; (rec {
inherit modifier keybindings;
terminal = "${pkgs.alacritty}/bin/alacritty";
inherit modifier keybindings terminal;
colors = {
focused = rec {
background = theme.background.normal;
text = theme."red".bright;
text = theme."green".bright;
border = background;
childBorder = border;
indicator = border;

View file

@ -1,4 +1,13 @@
{ lib, config, pkgs, modifier ? "Mod4", directional, workspace, launchers }:
{
modifier ? "Mod4",
directional,
workspace,
launchers,
scripts,
config,
pkgs,
lib,
}:
with lib; let mod = modifier;
@ -51,9 +60,9 @@ with lib; let mod = modifier;
);
# Application launchers
genLaunchers = ({ browser }: {
genLaunchers = ({ browser, terminal }: {
"${mod}+Tab" = "exec ${browser}";
"${mod}+Return" = "exec alacritty";
"${mod}+Return" = "exec ${terminal}";
});
# Layout manipulation
@ -62,6 +71,9 @@ with lib; let mod = modifier;
"${mod}+A" = "split v";
"${mod}+S" = "split h";
"${mod}+Mod1+A" = "layout toggle stacked splitv";
"${mod}+Mod1+S" = "layout toggle tabbed splith";
"${mod}+F" = "fullscreen toggle";
"${mod}+BackSpace" = "kill";
@ -97,9 +109,19 @@ with lib; let mod = modifier;
})))
);
# Utility scripts, for example for making screenshots.
utils = ({ lock ? null, sc ? null }:
(optionalAttrs (lock != null) {
"${mod}+Escape" = "exec ${lock}/bin/lock";
}) // (optionalAttrs (sc != null) {
"${mod}+d --release" = "exec ${sc}/bin/sc";
})
);
in (mkMerge [
(media { inherit (pkgs) mpc_cli pulseaudio; })
(utils scripts)
(genDirectional directional)
(genWorkspaces workspace)

View file

@ -0,0 +1,21 @@
# Utility scripts for use with a window manager.
{ pkgs, ... }: with pkgs; {
lock = writeShellApplication {
name = "lock";
runtimeInputs = [ i3lock ];
text = "i3lock";
};
sc = (writeShellApplication {
name = "sc";
runtimeInputs = [ xclip scrot ];
text = ''
env > /tmp/env_sc.txt
scrot -D :0 -ozs /tmp/sc.png 2>/tmp/aaa.txt
xclip -t "image/png" -sel clip -i < /tmp/sc.png 2>/tmp/bbb.txt
'';
});
}

View file

@ -1,19 +0,0 @@
# Haskell text faces and other stuff related to syntax highlighting
# for Haskell in Kakoune, because I prefer different color arrangements
# per language.
{ theme, pkgs, ... }: pkgs.writeTextFile (rec {
name = "common.kak";
destination = "/share/kak/colors/${name}";
text = with theme; ''
face global value rgb:${yellow.bright}
face global string rgb:${green.normal}
face global variable +a
face global module rgb:${green.normal}
face global operator rgb:${cyan.bright}
face global type rgb:${yellow.normal}
face global function rgb:${cyan.bright}
face global keyword rgb:${blue.normal}+b
face global builtin +b
'';
})

View file

@ -1,8 +0,0 @@
# Import syntax themes
{ lib, theme, pkgs, ... }: [
(import ./haskell.nix { inherit lib theme pkgs; })
(import ./rust.nix { inherit lib theme pkgs; })
(import ./nix.nix { inherit lib theme pkgs; })
(import ./common.nix { inherit lib theme pkgs; })
]

View file

@ -1,21 +0,0 @@
# Haskell text faces and other stuff related to syntax highlighting
# for Haskell in Kakoune, because I prefer different color arrangements
# per language.
{ theme, pkgs, ... }: pkgs.writeTextFile (rec {
name = "haskell.kak";
destination = "/share/kak/colors/${name}";
text = with theme; ''
face global value rgb:${green.bright}
face global string rgb:${green.bright}
face global variable +b
face global module rgb:${green.normal}
face global meta rgb:${misc.lime}
face global operator rgb:${cyan.bright}
face global type rgb:${yellow.normal}
face global function rgb:${cyan.bright}
face global attribute rgb:${blue.normal}
face global keyword rgb:${blue.normal}
face global builtin +b
'';
})

View file

@ -1,19 +0,0 @@
# Haskell text faces and other stuff related to syntax highlighting
# for Haskell in Kakoune, because I prefer different color arrangements
# per language.
{ theme, pkgs, ... }: pkgs.writeTextFile (rec {
name = "nix.kak";
destination = "/share/kak/colors/${name}";
text = with theme; ''
add-highlighter buffer/ regex '\b\s*(=)' 1:operator
face global string rgb:${green.normal}
face global operator rgb:${yellow.bright}+b
face global keyword rgb:${blue.normal}+b
face global meta rgb:${purple.bright}
face global builtin rgb:${blue.bright}+b
'';
})

View file

@ -1,44 +0,0 @@
# Haskell text faces and other stuff related to syntax highlighting
# for Haskell in Kakoune, because I prefer different color arrangements
# per language.
{ theme, pkgs, ... }: pkgs.writeTextFile (rec {
name = "rust.kak";
destination = "/share/kak/colors/${name}";
text = with theme; ''
# Types
face global variant rgb:${green.bright}+b
face global enum rgb:${green.bright}+b
face global struct rgb:${red.pastel}+b
face global alias rgb:${orange.normal}+b
face global primitive rgb:${misc.teal}+b
face global trait rgb:${purple.bright}+b
face global union rgb:${misc.lime}+b
# Other Rust-specific syntax elements
face global lifetime rgb:${cyan.bright}
face global format rgb:${orange.bright}+b
face global macro rgb:fc4cbf+b
# Keywords
face global keyword rgb:${blue.normal}
# Literals
face global literal rgb:${yellow.bright}
face global string rgb:${yellow.bright}
# Items
face global function rgb:${green.normal}
face global method function
face global module rgb:${misc.blueGrey}
# Other stuff
face global attribute comment
face global variable rgb:${foreground.normal}
face global property rgb:${misc.lime}
face global operator rgb:${yellow.normal}
face global punctuation rgb:${foreground.normal}
'';
})

View file

@ -1,213 +0,0 @@
{ lib, pkgs, config, ... }:
let kakrc = pkgs.writeTextFile (rec {
name = "kakrc.kak";
destination = "/share/kak/autoload/${name}";
text = with config.riley.theme; ''
# Line numbering
add-highlighter global/ number-lines -separator ' ' -hlcursor
# Setting the tabstop to 4 (even though I have an ultrawide monitor)
set-option global tabstop 4
set global ui_options ncurses_assistant=cat
# Use Alt-Tab to switch between open buffers
map global insert <a-tab> <esc>:buffer-next<ret>
map global normal <a-tab> :buffer-next<ret>
colorscheme common
face global LineNumbers rgb:${background.slight}
face global BufferPadding rgb:${background.slight}
face global LineNumberCursor rgb:${foreground.primary}
face global crosshairs_line "default,rgb:${background.normal}"
face global MenuForeground "default,blue"
face global MenuBackground "default,rgb:313131"
face global InlayHint rgb:828282
face global comment rgb:${foreground.slight}
'' + (lib.optionalString (config.riley.ide) ''
eval %sh{ kak-lsp --kakoune -s $kak_session }
hook global -group yeet ModuleLoaded rust %{
# Override the Rust highlighting with semantic
# tokens supplied by the LSP client
remove-hooks global rust-highlight
remove-highlighter shared/rust
# Request tokens
lsp-semantic-tokens
# Self-destruct this hook (it should only run once)
remove-hooks global yeet
}
# Load language-specific color schemes
hook global WinSetOption filetype=(haskell) %{
colorscheme haskell
lsp-enable-window
lsp-inlay-diagnostics-enable global
map global <tab> ': lsp-code-actions<ret>'
map global <ret> ': lsp-hover<ret>'
}
hook global WinSetOption filetype=(rust) %{
lsp-enable-window
lsp-inlay-diagnostics-enable window
colorscheme rust
hook window -group semtok BufReload .* lsp-semantic-tokens
hook window -group semtok NormalIdle .* lsp-semantic-tokens
hook window -group semtok InsertIdle .* lsp-semantic-tokens
hook -once -always window WinSetOption filetype=.* %{
remove-hooks window semtok
}
hook window ModeChange .*:.*:insert %{
remove-highlighter window/lsp_diagnostics
}
hook window ModeChange .*:insert:normal %{
lsp-inlay-diagnostics-enable window
}
set global lsp_inlay_diagnostic_sign '>'
map global normal <tab> ': lsp-code-actions<ret>'
map global normal <ret> ': lsp-hover<ret>'
}
hook global WinSetOption filetype=(nix) %{
colorscheme nix
lsp-enable-window
}
face global InlayDiagnosticWarning rgb:a39e31+f
face global InlayDiagnosticError rgb:ad494f+f
face global InlayDiagnosticHint rgb:4d965a+f
'');
});
# Syntax colors
colors = (import ./colors {
theme = config.riley.theme;
inherit lib pkgs;
});
# Config for kak-lsp
kak-lsp-config = pkgs.writeTextFile (rec {
name = "kak-lsp.toml";
destination = "/share/kak-lsp/${name}";
text = let semTok = (name: value: ''
[[semantic_tokens]]
token = "${name}"
face = "${value}"
''); in ''
[language.rust]
filetypes = [ "rust" ]
roots = [ "Cargo.toml" ]
command = "rust-analyzer"
[language.rust.settings.rust-analyzer]
semanticTokens = true
diagnostics.enabled = [ "unresolved-proc-macro" ]
cargo.loadOutDirsFromCheck = true
procMacro.enable = false
[language.haskell]
filetypes = [ "haskell" ]
roots = [ "Setup.hs", "stack.yaml", "*.cabal" ]
command = "haskell-language-server-wrapper"
args = [ "--lsp" ]
[language.nix]
filetypes = [ "nix" ]
roots = [ "flake.nix", "shell.nix", ".git", ".hg" ]
command = "rnix-lsp"
${lib.concatStringsSep "\n" (lib.mapAttrsToList semTok {
"enumMember" = "variant";
"enum" = "enum";
"union" = "union";
"struct" = "struct";
"typeAlias" = "alias";
"builtinType" = "primitive";
"trait" = "trait";
"interface" = "trait";
"method" = "method";
"function" = "function";
"namespace" = "module";
"boolean" = "literal";
"character" = "literal";
"number" = "literal";
"string" = "string";
"keyword" = "keyword";
"documentation" = "comment";
"comment" = "comment";
"escapeSequence" = "format";
"formatSpecifier" = "format";
"operator" = "operator";
"arithmetic" = "operator";
"bitwise" = "operator";
"comparison" = "operator";
"logical" = "operator";
"macro" = "macro";
"lifetime" = "lifetime";
"variable" = "variable";
"attribute" = "attribute";
"punctuation" = "punctuation";
}) }
'';
});
in {
environment.systemPackages = with pkgs; [
(pkgs.kakoune.override {
plugins = with kakounePlugins; [
# Custom config
kakrc
# Kakoune language server support
(symlinkJoin {
paths = [
# The language server client
kak-lsp
# Include default language servers
rnix-lsp
haskell-language-server
# Overwrite kak-lsp.toml
kak-lsp-config
];
name = "kak-lsp-${kak-lsp.version}";
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
wrapProgram $out/bin/kak-lsp --add-flags "--config $out/share/kak-lsp/kak-lsp.toml"
'';
})
] ++ colors;
})
];
}

38
modules/kak/colors.nix Normal file
View file

@ -0,0 +1,38 @@
{ theme, lib, pkgs }:
pkgs.writeTextFile (rec {
name = "colors.kak";
destination = "/share/kak/colors/${name}";
text = with theme; ''
face global comment rgb:828282
face global value rgb:${green.normal}
face global string rgb:${green.normal}
face global keyword rgb:${misc.blueGrey}
face global operator rgb:${cyan.normal}
face global function rgb:${cyan.normal}
face global builtin rgb:${orange.normal}
face global module rgb:${yellow.normal}
face global meta rgb:${green.bright}
face global type rgb:${blue.bright}
face global trait rgb:${purple.bright}
face global macro +b@meta
face global method function
face global variant rgb:${blue.normal}
face global LineNumbers rgb:${background.slight}
face global BufferPadding rgb:${background.slight}
face global LineNumberCursor rgb:${foreground.primary}
face global crosshairs_line default,rgb:212121
face global MenuForeground default,rgb:${blue.normal}
face global MenuBackground default,rgb:313131
face global DiagnosticWarning default,default,yellow+c
face global DiagnosticError default,default,red+c
face global DiagnosticHint default,default,green+c
face global Reference default,rgb:323232,default
'';
})

52
modules/kak/default.nix Normal file
View file

@ -0,0 +1,52 @@
{ lib, pkgs, config, ... }:
with pkgs.kakouneUtils;
let cfg = config.custom.kak;
theme = config.custom.gui.theme;
kak-crosshairs = buildKakounePlugin (rec {
name = "kak-crosshairs";
src = (pkgs.fetchFromGitHub {
owner = "insipx";
repo = name;
rev = "7edba13c535ce1bc67356b1c9461f5d261949d29";
sha256 = "sha256-VOn9GGHludJasEwcCv6t1Q3/63w9139MCEkdRDnTw6E";
});
});
in
with lib; {
options.custom.kak = {
enable = (mkEnableOption "kakoune editor") // { default = true; };
rust = mkEnableOption "Rust support in Kakoune";
ts = mkEnableOption "TypeScript support in Kakoune";
haskell = mkEnableOption "Haskell support in Kakoune";
python = mkEnableOption "Python 3.9 support in Kakoune";
nix = (mkEnableOption "Nix support in Kakoune") // { default = true; };
};
config = mkIf (cfg.enable) {
environment.systemPackages = [
(import ./kakoune.nix {
typescript = cfg.ts;
haskell = cfg.haskell;
python = cfg.python;
rust = cfg.rust;
nix = cfg.nix;
inherit kak-crosshairs;
inherit pkgs lib theme;
})
];
};
}

132
modules/kak/kak-lsp.nix Normal file
View file

@ -0,0 +1,132 @@
{
# Feature flags
typescript ? false,
haskell ? false,
clojure ? false,
python ? false,
rust ? false,
nix ? true,
# Build context
pkgs,
lib
}:
with lib;
with pkgs;
let semantic-tokens =
let mk = (name: value: ''
[[semantic_tokens]]
token = "${name}"
face = "${value}"
''); in concatStringsSep "\n" (mapAttrsToList mk {
"enumMember" = "variant";
"enum" = "enum";
"union" = "union";
"struct" = "struct";
"typeAlias" = "alias";
"builtinType" = "primitive";
"trait" = "trait";
"interface" = "trait";
"method" = "method";
"function" = "function";
"namespace" = "module";
"boolean" = "literal";
"character" = "literal";
"number" = "literal";
"string" = "string";
"keyword" = "keyword";
"documentation" = "comment";
"comment" = "comment";
"escapeSequence" = "format";
"formatSpecifier" = "format";
"operator" = "operator";
"arithmetic" = "operator";
"bitwise" = "operator";
"comparison" = "operator";
"logical" = "operator";
"macro" = "macro";
"macroBang" = "macro";
"lifetime" = "lifetime";
"variable" = "variable";
"attribute" = "attribute";
"punctuation" = "punctuation";
});
kak-lsp-config-text = concatStringsSep "\n" (
(optional (rust || haskell || clojure) semantic-tokens)
++ (optional rust ''
[language.rust]
filetypes = [ "rust" ]
roots = [ "Cargo.toml" ]
command = "rust-analyzer"
[language.rust.settings.rust-analyzer]
semanticTokens = true
diagnostics.enabled = [ "unresolved-proc-macro" ]
cargo.loadOutDirsFromCheck = true
procMacro.enable = false
'')
++ (optional nix ''
[language.nix]
filetypes = [ "nix" ]
roots = [ "flake.nix", "shell.nix", ".git", ".hg" ]
command = "rnix-lsp"
'')
++ (optional haskell ''
[language.haskell]
filetypes = [ "haskell" ]
roots = [ "Setup.hs", "stack.yaml", "*.cabal" ]
command = "haskell-language-server-wrapper"
args = [ "--lsp" ]
'')
++ (optional clojure ''
[language.clojure]
filetypes = ["clojure"]
roots = ["project.clj", "deps.edn", ".lsp/config.edn", ".git/"]
command = "clojure-lsp"
'')
++ (optional python ''
[language.python]
filetypes = [ "python" ]
roots = [ "setup.py", ".git", ".hg" ]
command = "pylsp"
'')
++ (optional typescript ''
[language.typescript]
filetypes = ["typescript", "javascript"]
roots = ["package.json"]
command = "rslint-lsp"
''));
kak-lsp-config = (pkgs.writeTextFile (rec {
name = "kak-lsp.toml";
destination = "/share/kak-lsp/${name}";
text = kak-lsp-config-text;
}));
in (symlinkJoin {
name = "kak-lsp-${kak-lsp.version}";
nativeBuildInputs = [ makeWrapper ];
paths = with kakounePlugins; [
# The language server client
kak-lsp
# Overwrite kak-lsp.toml
kak-lsp-config
] ++ (optional nix rnix-lsp)
++ (optional typescript rslint)
++ (optional haskell haskell-language-server)
++ (optional clojure clojure-lsp)
++ (optional python python39Packages.python-lsp-server)
++ (optional rust rust-analyzer);
postBuild = ''
wrapProgram $out/bin/kak-lsp --add-flags "--config $out/share/kak-lsp/kak-lsp.toml"
'';
})

70
modules/kak/kakoune.nix Normal file
View file

@ -0,0 +1,70 @@
# Preconfigured kakoune editor.
{
# Feature flags
clipboard ? false,
typescript ? false,
haskell ? false,
clojure ? false,
python ? false,
rust ? false,
nix ? true,
# Allow extra plugins to be defined
# outside of the package
extraPlugins ? [],
# Plugins
kak-crosshairs,
# Color theme
theme,
# Build context
pkgs,
lib
}:
let kakrc = (import ./kakrc.nix {
inherit clipboard
typescript
haskell
clojure
python
rust
nix
theme
pkgs
lib;
});
colors = (import ./colors.nix {
inherit theme
pkgs
lib;
});
kak-lsp = (import ./kak-lsp.nix {
inherit typescript
haskell
clojure
python
rust
nix
pkgs
lib;
});
in (pkgs.kakoune.override {
plugins = [
# Configuration
kak-lsp
colors
kakrc
# Plugins
kak-crosshairs
] ++ extraPlugins;
})

223
modules/kak/kakrc.nix Normal file
View file

@ -0,0 +1,223 @@
# Defines the kakrc.
{
# Feature flags
clipboard ? false,
typescript ? false,
haskell ? false,
clojure ? false,
python ? false,
rust ? false,
nix ? true,
# Color theme
theme,
# Build tools
pkgs,
lib,
}:
let keybinds = ''
map global insert <a-tab> <esc>:buffer-next<ret>
map global normal <a-tab> :buffer-next<ret>
'' + (lib.optionalString clipboard ''
map global user y <a-|>c<ret>
map global user p !p<ret>
'');
# Initialization code for IDE mode needed for every supported
# language, and inlay diagnostics.
ide-init = ''
lsp-enable-window
hook window ModeChange .*:.*:insert %{
lsp-inlay-diagnostics-disable window
remove-highlighter window/lsp_diagnostics
}
hook window ModeChange .*:insert:normal %{
lsp-inlay-diagnostics-enable window
}
'';
# Implies `ide-init`. Adds code actions and hover.
ide-core = ''
${ide-init}
map buffer normal <tab> ': lsp-code-actions<ret>'
map buffer normal <ret> ': lsp-hover<ret>'
'';
# Implies `ide-core`, which implies `ide-init`.
ide-full = ''
${ide-core}
hook window -group semtok BufReload .* lsp-semantic-tokens
hook window -group semtok NormalIdle .* lsp-semantic-tokens
hook window -group semtok InsertIdle .* lsp-semantic-tokens
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window semtok }
map global normal <up> ': lsp-previous-symbol<ret>'
map global normal <down> ': lsp-next-symbol<ret>'
map global normal <a-down> ': lsp-hover-next-symbol<ret>'
map global normal <a-up> ': lsp-hover-previous-symbol<ret>'
map global normal <a-left> ': lsp-previous-location *goto*<ret>'
map global normal <a-right> ': lsp-next-location *goto*<ret>'
''; in
# Nix hacking-related configuration. Nix has a very weak language
# server, and it basically only supports `ide-init` (for completions).
let nix-config = (lib.optionalString nix ''
hook global WinSetOption filetype=nix %{
${ide-init}
face global keyword rgb:${theme.cyan.normal}
}
'');
# Sometimes work requires me to touch the frontend. Ew. `ide-core`
# suffices here.
typescript-config = (lib.optionalString typescript ''
hook global WinSetOption filetype=(javascript|typescript) %{
${ide-core}
}
'');
# Python-related config. Python does not support more features than
# those in `ide-core`.
python-config = (lib.optionalString python ''
hook global WinSetOption filetype=python %{
${ide-core}
face window keyword rgb:${theme.green.bright}
face window meta keyword
}
'');
# Clojure-lsp has all the IDE features I use.
clojure-config = (lib.optionalString clojure ''
hook global WinSetOption filetype=clojure %{
${ide-full}
}
'');
# Haskell development. Haskell has a language server with
# the features in `ide-full`.
haskell-config = (lib.optionalString haskell ''
hook global WinSetOption filetype=haskell %{
${ide-full}
set-option buffer tabstop 2
face global variable rgb:${theme.purple.normal}
face global attribute keyword
face global operator keyword
face global keyword rgb:${theme.blue.bright}
face global value string
face global meta rgb:${theme.pink.normal}
}
'');
# Rust development. Rust's language servers all support the
# `ide-full` features.
rust-config = (lib.optionalString rust ''
hook global WinSetOption filetype=rust %{
${ide-full}
hook global -group yeet ModuleLoaded rust %{
# Override the Rust highlighting with semantic
# tokens supplied by the LSP client
remove-hooks global rust-highlight
remove-highlighter shared/rust
# Request tokens
lsp-semantic-tokens
# Self-destruct this hook (it should only run once)
remove-hooks global yeet
}
hook global NormalIdle .* %{ lsp-highlight-references }
hook global InsertMove .* %{ lsp-highlight-references }
face global type rgb:${theme.blue.normal}
face global trait rgb:${theme.purple.normal}
face global macro rgb:${theme.green.bright}
face global format rgb:${theme.orange.bright}
face global attribute rgb:${theme.orange.bright}
face global operator rgb:${theme.yellow.normal}
face global function rgb:${theme.green.bright}
face global keyword rgb:${theme.misc.blueGrey}
face global variable white
face global value white
face global meta white
face global alias rgb:${theme.orange.normal}
face global enum type
face global struct type
face global union type
face global lifetime rgb:${theme.pink.pastel}
face global module rgb:ffffff
}
'');
in pkgs.writeTextFile (rec {
name = "kakrc.kak";
destination = "/share/kak/autoload/${name}";
text = ''
set global tabstop 4
set global indentwidth 4
eval %sh{ kak-lsp --kakoune -s $kak_session }
add-highlighter global/ number-lines -separator ' ' -hlcursor
face global InlayHint rgb:828282
face global InlayDiagnosticWarning rgb:a39e31+f
face global InlayDiagnosticError rgb:ad494f+f
face global InlayDiagnosticHint rgb:4d965a+f
face global InlayDiagnosticInfo rgb:4d965a+f
hook global WinSetOption filetype=markdown %{
hook window -group spellck BufReload .* spell
hook window -group spellck NormalIdle .* spell
hook window -group spellck InsertIdle .* spell
hook -once -always window WinSetOption filetype=.* %{
remove-hooks window spellck
}
}
${keybinds}
${typescript-config}
${haskell-config}
${clojure-config}
${python-config}
${rust-config}
${nix-config}
hook global KakBegin .* %{
cursorline
colorscheme colors
}
'';
})

27
modules/mpd.nix Normal file
View file

@ -0,0 +1,27 @@
{ config, pkgs, lib, ... }:
let cfg = config.riley.mpd; in
with lib; {
options.riley.mpd = {
enable = mkEnableOption "music player daemon";
};
config = mkIf (cfg.enable) {
# Enable the service
home-manager.users."riley" = {
services.mpd = {
enable = true;
musicDirectory = "$HOME/media/music";
};
};
users.users."riley".packages = with pkgs; [
mpc_cli
];
};
}

View file

@ -15,4 +15,10 @@
packages = with pkgs; [ openssh ];
};
users.users."root" = {
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGk/nBXhr3xWtbXBBkCuwqE6OixpRXCfscfxibgcCsTR me@riley.lgbt"
];
};
}

11
overlays/default.nix Normal file
View file

@ -0,0 +1,11 @@
self: super: {
minecraft =
let version = "2.2.2012";
in super.minecraft.overrideAttrs (old: {
inherit version;
src = self.fetchurl {
url = "https://launcher.mojang.com/download/linux/x86_64/minecraft-launcher_${version}.tar.gz";
sha256 = "sha256-er+g/0pqsS5mDcZ5ID9kATuF3RwDQThue1mc/XRVms8=";
};
});
}

9
scripts/README.md Normal file
View file

@ -0,0 +1,9 @@
# Scripts
This directory contains nix derivations for shell scripts I want to use across
devices.
| Filename | Scripts | Description |
| ---------- | -------- | ------------------------------------------ |
| `clip.nix` | `c`, `p` | Copy and paste abstractions |
| `sc.nix` | `sc` | Area screenshot tool with clip integration |

12
scripts/bitwarden.nix Normal file
View file

@ -0,0 +1,12 @@
{ pkgs, ... }: with pkgs; {
# Get a password entry from the list
pw = (writeShellApplication {
name = "pw";
runtimeInputs = [ rbw skim ];
text = ''
x=$(rbw list | sk) && rbw "$@" "$x"
'';
});
}

17
scripts/clip.nix Normal file
View file

@ -0,0 +1,17 @@
{ pkgs, ... }: with pkgs; {
# Copy something to the clipboard
c = (writeShellApplication {
name = "c";
runtimeInputs = [ xclip ];
text = "xclip -sel clip -i";
});
# Paste something from the clipboard
p = (writeShellApplication {
name = "p";
runtimeInputs = [ xclip ];
text = "xclip -sel clip -o";
});
}

12
scripts/sc.nix Normal file
View file

@ -0,0 +1,12 @@
{ pkgs, ... }: with pkgs; {
# Take a screenshot of a selected area and put it in the clipboard.
sc = (writeShellApplication {
name = "sc";
runtimeInputs = [ xclip scrot ];
text = ''
scrot -z -s - | tee /tmp/sc.png | xclip -i -sel clip -t image/png
'';
});
}

8
secrets/secrets.nix Normal file
View file

@ -0,0 +1,8 @@
let sif = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOIXreYQgV6lS0rJ1NlAbgq3Iv5FJ8o1MOr08NhLTGFG";
thor = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILniE+LdfdV9V9+Zj5gJXqKEv1CzQaEySy1u5OdbKa8d";
in {
"website.age".publicKeys = [
thor
sif
];
}

10
secrets/website.age Normal file
View file

@ -0,0 +1,10 @@
age-encryption.org/v1
-> ssh-ed25519 qlXMTg b+IgpHsZOeqs3rHFs6BE2kXFKh0ya5Qr8WKqgNO5rDA
a/LM3SIob+udnVsqIqUkR7xdE7fa1TyQhOZbjQRsnV0
-> ssh-ed25519 ZEUNCQ PErAc4AM7H1zYFv4OlFkZVGJlze6nTvmmEt1y+x4tDY
2HwpQ+2B/zXatOCKUPSabRu2ZWcTTODzheDkxngcQi4
-> j]Pn\)-grease uQI:D GZvyy
9/Z0dk6R1bUhJbN32W3id9q959Nn0+jVL2dzDxLDHjacDeldJ4WuxrEzl0xdMUNE
YaFJepKcRKR9
--- X8YEMtOmM0Mr71UzVA8gKozDYk5S53XSmBxjpSP6PbQ
‡Ì/‡Å&!.¼l1d)õ©›:í=T<>öÖÿÉ<C3BF>ï P^º/ÇfV†F0$ç_Ƀ