This commit is contained in:
Aether 2022-01-11 17:44:40 +00:00
parent 2029e1b57e
commit ec00c09f2e
58 changed files with 2340 additions and 0 deletions

View File

@ -0,0 +1,30 @@
{
languageserver = {
dhall = {
command = "dhall-lsp-server";
filetypes = [ "dhall" ];
};
haskell = {
command = "haskell-language-server-wrapper";
args = [ "--lsp" ];
rootPatterns = [
"stack.yaml"
"hie.yaml"
".hie-bios"
"BUILD.bazel"
".cabal"
"cabal.project"
"package.yaml"
];
filetypes = [ "hs" "lhs" "haskell" ];
};
nix = {
command = "rnix-lsp";
filetypes = [ "nix" ];
};
};
"yank.highlight.duration" = 700;
}

96
config/neovim/coc.vim Normal file
View File

@ -0,0 +1,96 @@
" ------------------- COC config -----------------------
set updatetime=300
set shortmess+=c
set signcolumn=yes
set nobackup
set nowritebackup
set cmdheight=2
" Use <c-space> for trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> for confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[c` and `]c` for navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Remap for do action format
"nmap <silent> F <Plug>(coc-action-format) "does not work
nnoremap <silent> F :call CocAction('format')<CR>
" Temporary command to run brittany in Haskell projects (ghcide does not support it yet)
nnoremap <leader>af :r !brittany --write-mode=inplace %:p<CR>
" Temporary command to run hlint in Haskell projects (ghcide does not support it yet)
nnoremap <leader>al :AsyncRun hlint %:p<CR>
" Show signature help
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
" Use K for show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
" autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Show all diagnostics
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
nnoremap <silent> <M-B> :call CocRequest('metals', 'workspace/executeCommand', { 'command': 'build-import' })<CR>
"nnoremap <silent> <M-Z> :ccl<CR>
" COC Snippets
" Use <C-l> for trigger snippet expand.
imap <C-l> <Plug>(coc-snippets-expand)
" Use <C-j> for select text for visual placeholder of snippet.
vmap <C-j> <Plug>(coc-snippets-select)
" Use <C-j> for jump to next placeholder, it's default of coc.nvim
let g:coc_snippet_next = '<c-j>'
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
let g:coc_snippet_prev = '<c-k>'
" Use <C-j> for both expand and jump (make expand higher priority.)
imap <C-j> <Plug>(coc-snippets-expand-jump)

38
config/neovim/config.vim Normal file
View File

@ -0,0 +1,38 @@
filetype off
let mapleader=','
set shell=/run/current-system/sw/bin/fish
set viewoptions=folds,options,cursor,unix,slash
set encoding=utf-8
set termguicolors
syntax on
set backspace=2
set laststatus=2
set noshowmode
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set number
set numberwidth=1
set cmdheight=3
set textwidth=0
set linebreak
set showmatch
set matchtime=0
set clipboard=unnamedplus
set cursorline
set incsearch
set ignorecase
set smartcase
nnoremap Q <Nop>
nnoremap gQ <Nop>
:tnoremap <Esc> <C-\><C-n>

12
config/neovim/plugins.vim Normal file
View File

@ -0,0 +1,12 @@
" let g:hoogle_search_count = 20
" au BufNewFile,BufRead *.hs map <silent> <F1> :Hoogle<CR>
" au BufNewFile,BufRead *.hs map <silent> <C-c> :HoogleClose<CR>
nnoremap <C-t>n :NERDTreeFocus<CR>
map <C-t>f :NERDTreeToggle<CR>
map <C-t>s :NERDTreeFind<CR>
" let g:hoogle_fzf_cache_file = '~/.cache/fzf-hoogle/cache.json'
" nnoremap <leader>h :Hoogle <CR>
let g:vimtex_compiler_method = 'tectonic'

39
default.nix Executable file
View File

@ -0,0 +1,39 @@
{ config, inputs, lib, pkgs, ... }:
let
inherit (lib) _;
in {
imports =
[ inputs.home-manager.nixosModules.home-manager ]
++ _.mapModulesRec' ./modules import;
# nix flake check bypasses, can be changed in the actual hosts
# config, useful for testing
fileSystems."/".device = lib.mkDefault "/dev/disk/by-label/nixos";
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.systemd-boot.configurationLimit = 10;
nix = let
registry = lib.mapAttrs (_: v: { flake = v; }) (_.filterSelf inputs);
in {
package = pkgs.nixFlakes;
autoOptimiseStore = true;
extraOptions = "experimental-features = nix-command flakes";
binaryCaches = [
"https://nix-community.cachix.org"
];
binaryCachePublicKeys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
registry = registry // { dotfiles.flake = inputs.self; };
};
environment.systemPackages = with pkgs; [
curl git wget neovim
];
i18n.defaultLocale = "en_US.UTF-8";
system.stateVersion = lib.mkDefault "21.05";
}

238
flake.lock Executable file
View File

@ -0,0 +1,238 @@
{
"nodes": {
"agenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1641576265,
"narHash": "sha256-G4W39k5hdu2kS13pi/RhyTOySAo7rmrs7yMUZRH0OZI=",
"owner": "ryantm",
"repo": "agenix",
"rev": "08b9c96878b2f9974fc8bde048273265ad632357",
"type": "github"
},
"original": {
"owner": "ryantm",
"repo": "agenix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1641205782,
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1641459437,
"narHash": "sha256-z0IOcc6LLbVhyri/aTyWzRqJs3p1pBK9idOiMwCWiqs=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "c751aeb19e84a0a777f36fd5ea73482a066bb406",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "master",
"repo": "home-manager",
"type": "github"
}
},
"libnbtplusplus": {
"flake": false,
"locked": {
"lastModified": 1591558203,
"narHash": "sha256-QgvNvaoFflCXEPCCFBCeZvYTpuiwScBG7EosUgFwFNQ=",
"owner": "multimc",
"repo": "libnbtplusplus",
"rev": "dc72a20b7efd304d12af2025223fad07b4b78464",
"type": "github"
},
"original": {
"owner": "multimc",
"repo": "libnbtplusplus",
"type": "github"
}
},
"meson": {
"flake": false,
"locked": {
"lastModified": 1640155612,
"narHash": "sha256-XrEIlf0W8mKEa97Uyc0w/187KBGEZOD+dJFNsn3UeNg=",
"owner": "mesonbuild",
"repo": "meson",
"rev": "06aad5233e6bec97bfe21ae79c85aa7171089d3b",
"type": "github"
},
"original": {
"owner": "mesonbuild",
"ref": "0.60",
"repo": "meson",
"type": "github"
}
},
"multimc": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs",
"quazip": "quazip"
},
"locked": {
"lastModified": 1641769038,
"narHash": "sha256-IGk8n00m7riuYLnR+3Nbo70YHJBOQv+nakynN/gtoY0=",
"owner": "PolyMC",
"repo": "PolyMC",
"rev": "3fa6e2243047005505a3de6f133feaa2f2eeb10a",
"type": "github"
},
"original": {
"owner": "PolyMC",
"repo": "PolyMC",
"type": "github"
}
},
"nixos-hardware": {
"locked": {
"lastModified": 1639986101,
"narHash": "sha256-Ow0+pkY7qMw6lMAvR1mEdUT9svJnrkbaRoqp4bkMTpg=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "3f92db38374b2977aea8daf4c4fe2fa0eddbd60c",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1641528457,
"narHash": "sha256-FyU9E63n1W7Ql4pMnhW2/rO9OftWZ37pLppn/c1aisY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "ff377a78794d412a35245e05428c8f95fef3951f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1640139330,
"narHash": "sha256-Nkp3wUOGwtoQ7EH28RLVJ7EqB/e0TU7VcsM7GLy+SdY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "81cef6b70fb5d5cdba5a0fef3f714c2dadaf0d6d",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1641528457,
"narHash": "sha256-FyU9E63n1W7Ql4pMnhW2/rO9OftWZ37pLppn/c1aisY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ff377a78794d412a35245e05428c8f95fef3951f",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"quazip": {
"flake": false,
"locked": {
"lastModified": 1633895098,
"narHash": "sha256-+Of0M2IAoTf1CyC0teCpsyurv6xfqiBo84V49dSeNTA=",
"owner": "multimc",
"repo": "quazip",
"rev": "b1a72ac0bb5a732bf887a535ab75c6f9bedb6b6b",
"type": "github"
},
"original": {
"owner": "multimc",
"repo": "quazip",
"type": "github"
}
},
"root": {
"inputs": {
"agenix": "agenix",
"home-manager": "home-manager",
"meson": "meson",
"multimc": "multimc",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_2",
"nixpkgs-unstable": "nixpkgs-unstable",
"sway-borders": "sway-borders"
}
},
"sway-borders": {
"flake": false,
"locked": {
"lastModified": 1640037473,
"narHash": "sha256-gCdnim7excF11GEoni5YbIGTWSIx+wjHc8NO8lVNFts=",
"owner": "fluix-dev",
"repo": "sway-borders",
"rev": "5f4162f449b19f6d198b365fc6d3dd0febc065e2",
"type": "github"
},
"original": {
"owner": "fluix-dev",
"repo": "sway-borders",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

73
flake.nix Executable file
View File

@ -0,0 +1,73 @@
{
description = "Frosted Flakes";
inputs = {
# NixOS unstable
nixpkgs.url = "nixpkgs/nixos-unstable";
# nixpkgs.url = "nixpkgs/nixos-21.05";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
# home-manager
home-manager.url = "github:nix-community/home-manager/master";
# home-manager.url = "github:nix-community/home-manager/release-21.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# agenix - age-encrypted secrets
agenix.url = "github:ryantm/agenix";
agenix.inputs.nixpkgs.follows = "nixpkgs";
# nixos-hardware
nixos-hardware.url = "github:nixos/nixos-hardware";
nixos-hardware.inputs.nixpkgs.follows = "nixpkgs";
/*
# fzf-hoogle
fzf-hoogle-vim.url = "github:monkoose/fzf-hoogle.vim";
fzf-hoogle-vim.flake = false;
# asyncrun-vim
asyncrun-vim.url = "github:skywind3000/asyncrun.vim";
asyncrun-vim.flake = false;
*/
meson.url = "github:mesonbuild/meson/0.60";
meson.flake = false;
sway-borders.url = "github:fluix-dev/sway-borders";
sway-borders.flake = false;
# blender-30.url = "github:blender/blender/blender-v3.0-release";
# blender-30.flake = false;
multimc.url = "github:PolyMC/PolyMC";
};
outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, ... }:
let
system = "x86_64-linux";
lib = import ./lib { inherit pkgs inputs; lib = nixpkgs.lib; };
inherit (lib._) mapModules mapModulesRec mkHost;
mkPkgs = pkgs: overlays: import pkgs {
inherit system;
config.allowUnfree = true;
overlays = overlays ++ (lib.attrValues self.overlays);
};
pkgs = mkPkgs nixpkgs [ self.overlay ];
in {
packages."${system}" = mapModules ./packages (p: pkgs.callPackage p {});
overlay = final: prev: {
_ = self.packages."${system}";
# meson = inputs.meson;
# sway-unwrapped = inputs.sway-borders;
# blender = inputs.blender-30;
unstable = mkPkgs nixpkgs-unstable [];
};
overlays = mapModules ./overlays import ++ [ inputs.polymc.overlay.${system} ];
nixosModules = mapModulesRec ./modules import;
nixosConfigurations = mapModules ./hosts (mkHost system);
devShell."${system}" =
import ./shell.nix { inherit pkgs; };
};
}

63
hosts/firepit/default.nix Normal file
View File

@ -0,0 +1,63 @@
{ pkgs, inputs, lib, ... }:
{
imports = [
./hardware-configuration.nix
];
user = {
packages = with pkgs; [
curl
];
};
defaultUsers = {
aether = {
packages = [ ];
shell = "zsh";
extraGroups = [ "wheel" ];
};
oatmealine = {
packages = [ ];
shell = "zsh";
extraGroups = [ "wheel" ];
};
};
keyboard = {
locale = "en_US.UTF-8";
variant = "qwerty";
};
modules = {
# theme.active = "still";
shell.zsh.enable = true;
security = {
isLocalMachine = false;
};
desktop = {
editors = {
neovim.enable = true;
};
};
dev = {
};
services = {
ssh.enable = true;
postgres.enable = true;
gitea = {
enable = true;
site = "git.oat.zone";
};
};
};
time.timeZone = "Europe/Frankfurt";
programs.ssh.startAgent = true;
services.openssh.startWhenNeeded = true;
networking = {
hostName = "firepit";
};
}

View File

@ -0,0 +1,11 @@
let
userAether = "<...>";
userOatmealine = "<...>";
in {
"aether" = {
"userAether.age".publicKeys = [ userAether ];
};
"oatmealine" = {
"userOatmealine.age".publicKeys = [ userOatmealine ];
};
}

View File

@ -0,0 +1,98 @@
{ pkgs, inputs, lib, ... }:
{
imports = [
./hardware-configuration.nix
];
user = {
packages = with pkgs; [
curl
dolphin
discord
firefox-wayland
wl-clipboard
inkscape
blender
];
};
defaultUsers = {
aether = {
packages = [ ];
uid = 1024;
isNormalUser = true;
shell = "zsh";
extraGroups = [ "wheel" ];
};
};
keyboard = {
locale = "en_US.UTF-8";
variant = "qwerty";
};
modules = {
# theme.active = "still";
shell.zsh.enable = true;
security = {
isLocalMachine = true;
};
desktop = {
sway = {
enable = true;
term = "alacritty";
};
apps = {
mpc.enable = true;
alacritty.enable = true;
obs.enable = true;
firefox.enable = true;
};
editors = {
neovim.enable = true;
codium.enable = true;
};
};
dev = {
llvm.enable = true;
haskell.enable = true;
c.enable = true;
};
services = {
ssh.enable = true;
mpd = {
enable = true;
# TODO: Make this more dynamic?
musicDir = "/home/aether/Music";
};
};
};
# Doxxing live stream
time.timeZone = "Europe/Dublin";
programs.ssh.startAgent = true;
services.openssh.startWhenNeeded = true;
# Fuck sudo all my homies hate sudo
security.sudo.enable = false;
security.doas = {
enable = true;
extraRules = [
{ users = [ "aether" ]; keepEnv = true; }
];
};
# Weird hack to get GDM to not explode on startup
# TODO: This might not be needed anymore
systemd.services."getty@tty1".enable = false;
systemd.services."autovt@tty1".enable = false;
networking = {
hostName = "subsurface";
networkmanager.enable = true;
useDHCP = false;
interfaces.wlp1s0.useDHCP = true;
};
}

View File

@ -0,0 +1,78 @@
# 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, inputs, modulesPath, ... }:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
# inputs.nixos-hardware.nixosModules.microsoft-surface
];
# Kernel Modules
boot = {
initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
initrd.kernelModules = [ ];
# kernelPackages = pkgs.linuxPackages_zen;
extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
kernelModules = [ "kvm-intel" "v4l2loopback" ];
loader = {
systemd-boot = {
enable = true;
configurationLimit = 10;
};
efi.canTouchEfiVariables = true;
};
};
# Modules
modules.hardware = {
audio = {
enable = true;
enableExtraCompat = true;
};
graphics.enable = true;
fs = {
enable = true;
ssd.enable = true;
};
};
# HiDPI
hardware.video.hidpi.enable = true;
# CPU
nix.maxJobs = lib.mkDefault 4;
hardware.cpu.intel.updateMicrocode = true;
# Power Management
powerManagement = {
powertop.enable = true;
cpuFreqGovernor = lib.mkDefault "powersave";
};
environment.systemPackages = with pkgs; [
brightnessctl
];
# Filesystems
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/eb56fb0a-a35d-472c-8704-6eec5ceea999";
fsType = "f2fs";
};
"/boot" = {
device = "/dev/disk/by-uuid/4669-2B0A";
fsType = "vfat";
};
/*
"/home/aether/Downloads" = {
fsType = "tmpfs";
};
*/
};
swapDevices = [{ device = "/dev/disk/by-uuid/74226c30-e72f-4576-8349-8e77e844e875"; }];
}

View File

@ -0,0 +1,6 @@
let
firepitAccess = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoaiYQuYPYO217IA8rGIVvbQCoVaqERGAGevq+WxutrcdUZraa2Zp44GEZEmNFVNlgm2FtkOV42vqwnx2gfkHmuYA38Cov9jbxtIv4ytaWve+UniNBtUF9De0ULqKTUErk5iBX7gBpg4hY2+GVSSrYJ4KZIwDbA6uNj7PTyQDSZrGfQMbFR52HEXttehg7/vMXUVwhnakpKk3v21bCQRNzc3K9dcFUDSTH1uOE1oEfKhGp2zHtnknLDlMIhGQcpwfOKPqURsbzXpln1EyEMlrudjMRDg/ZKsKxYuW0Lnbxqqifgm9ERvSeq+517j3QA2Z6EWLY5yejgcDiyDy8bvqV";
in {
"firepitAccess.age".publicKeys = [ firepitAccess ];
"firepitAccess.age".owner = "aether";
}

20
lib/README.md Normal file
View File

@ -0,0 +1,20 @@
# Lib
The `default.nix` defines a lib extended with a `_` attribute under which mine
custom lib functions live. The `default.nix` loads every `.nix` file in the
`libs` (current) directory and imports it.
The importing is quite simple:
1. First the `libsInFolder` reads the contents of the `libs` directory, filters
out non `.nix` files and the `default.nix` file and then returns a list of
paths to the individual `.nix` files it found.
2. This list gets passed to `importLibs` which imports the libraries and
merges the individual imported attribute sets together, so that all the
functions are available directly under one attribute set.
3. This attribute then gets bind to the `_` attribute in the `lib` extension.
Individual `.nix` files can use the functions defined in other local library
files normally using the `nix._.someFunctionName`.
## Overview
TODO

129
lib/colors.nix Normal file
View File

@ -0,0 +1,129 @@
{ lib, ... }:
let
inherit (builtins) elemAt listToAttrs substring;
inherit (lib) concatStringsSep fixedWidthString nameValuePair
stringToCharacters sublist toInt toUpper zipListsWith;
inherit (lib._) joinWithSep;
in rec {
/* Converts a hex color string to RGB triplet, an array of exactly 3 elements
Type:
toRGB :: String -> [Int]
Example:
toRGB "ffFFff"
=> [ 255 255 255 ]
*/
toRGB = hex: let
chars = stringToCharacters hex;
r = sublist 0 2 chars;
g = sublist 2 2 chars;
b = sublist 4 2 chars;
/* Converts a pair of characters (array of two strings, each of one char
long) in hexadecimal to a number. Expects a valid hexadecimal string.
Type:
hexPairToNum :: [String] -> Int
Example:
hexPairToNum [ "F" "1" ]
=> 241
*/
hexPairToNum = pair: let
c1 = elemAt pair 0; c2 = elemAt pair 1;
hexMapping = {
"A" = 10;
"B" = 11;
"C" = 12;
"D" = 13;
"E" = 14;
"F" = 15;
};
toNum = c: if hexMapping ? ${toUpper c} then hexMapping.${toUpper c} else toInt c;
in 16 * (toNum c1) + (toNum c2);
in [
(hexPairToNum r)
(hexPairToNum g)
(hexPairToNum b)
];
/* Both hexColor and rgbColor accept a color in 6 char long hexadecimal
representation. Their variants hexColor' and rgbaColor accept an
additional parameter opacity specified as an int in range from 0 to 100.
*/
/* Type:
hexColor :: String -> String
Example:
hexColor "FECACA"
=> "#FECACA"
*/
hexColor = color: "#" + color;
/* Type:
hexColor' :: String -> Int -> String
Example:
hexColor' "FECACA" 54
=> "#FECACA54"
*/
hexColor' = color: opacity: "#" + color + toString opacity;
_rgbColor = color: extra: "(" + (joinWithSep ((toRGB color) ++ extra) ", ") + ")";
/* Type:
rgbColor :: String -> String
Example:
rgbColor "FFFFFF"
=> "rgb(255, 255, 255)"
*/
rgbColor = color: "rgb" + _rgbColor color [];
/* Type:
rgbaColor :: String -> Int -> String
Example:
rgbaColor "FFFFFF" 42
=> "rgba(255, 255, 255, 0.42)"
*/
rgbaColor = color: _opacity: let
opacityStr = fixedWidthString 3 "0" (toString _opacity);
opacity = substring 0 1 opacityStr + "." + substring 1 2 opacityStr;
in "rgba" + _rgbColor color [opacity];
/* colors defines a color palette according to the Tailwind colors:
https://tailwindcss.com/docs/customizing-colors#color-palette-reference
Each individual color has 10 variants, for example to access the variant
700 of color red following notation is used: colors.red._700
The _ in front of the variant is there because numbers cannot be
used as keys.
*/
colors = let
scaleDef = [ 50 100 200 300 400 500 600 700 800 900 ];
scale = s: listToAttrs (zipListsWith (variant: color: nameValuePair "_${toString variant}" color) scaleDef s);
in rec {
# Default palette
coolGray = scale [ "F9FAFB" "F3F4F6" "E5E7EB" "D1D5DB" "9CA3AF" "6B7280" "4B5563" "374151" "1F2937" "111827" ];
red = scale [ "FEF2F2" "FEE2E2" "FECACA" "FCA5A5" "F87171" "EF4444" "DC2626" "B91C1C" "991B1B" "7F1D1D" ];
amber = scale [ "FFFBEB" "FEF3C7" "FDE68A" "FCD34D" "FBBF24" "F59E0B" "D97706" "B45309" "92400E" "78350F" ];
emerald = scale [ "ECFDF5" "D1FAE5" "A7F3D0" "6EE7B7" "34D399" "10B981" "059669" "047857" "065F46" "064E3B" ];
blue = scale [ "EFF6FF" "DBEAFE" "BFDBFE" "93C5FD" "60A5FA" "3B82F6" "2563EB" "1D4ED8" "1E40AF" "1E3A8A" ];
indigo = scale [ "EEF2FF" "E0E7FF" "C7D2FE" "A5B4FC" "818CF8" "6366F1" "4F46E5" "4338CA" "3730A3" "312E81" ];
violet = scale [ "F5F3FF" "EDE9FE" "DDD6FE" "C4B5FD" "A78BFA" "8B5CF6" "7C3AED" "6D28D9" "5B21B6" "4C1D95" ];
pink = scale [ "FDF2F8" "FCE7F3" "FBCFE8" "F9A8D4" "F472B6" "EC4899" "DB2777" "BE185D" "9D174D" "831843" ];
# Extra
blueGray = scale [ "F8FAFC" "F1F5F9" "E2E8F0" "CBD5E1" "94A3B8" "64748B" "475569" "334155" "1E293B" "0F172A" ];
# Aliases
gray = coolGray;
yellow = amber;
green = emerald;
purple = violet;
};
}

25
lib/default.nix Normal file
View File

@ -0,0 +1,25 @@
# _ _ _
# | (_) |__
# | | | '_ \
# | | | |_) |
# |_|_|_.__/
#
{ inputs, lib, pkgs, ... }:
lib.extend (lib: super:
let
inherit (builtins) attrNames map readDir;
inherit (lib) filterAttrs foldr hasSuffix;
importLib = file: import file { inherit inputs lib pkgs; };
merge = foldr (a: b: a // b) {};
importLibs = libs: merge (map importLib libs);
isLib = name: type: type == "regular" && name != "default.nix" && hasSuffix ".nix" name;
libPath = name: "${toString ./.}/${name}";
libsInFolder = map libPath (attrNames (filterAttrs isLib (readDir ./.)));
in {
_ = importLibs libsInFolder;
}
)

29
lib/modules.nix Normal file
View File

@ -0,0 +1,29 @@
{ lib, ... }:
let
inherit (builtins) attrValues pathExists readDir;
inherit (lib) filterAttrs hasSuffix mapAttrs' mkDefault mkOption
nameValuePair nixosSystem removeSuffix types;
inherit (lib._) mapFilterAttrs attrValuesRec;
in rec {
mapModules' = dir: fn: dirfn:
mapFilterAttrs
(_: v: v != null)
(name: type:
let
path = "${toString dir}/${name}";
in
if type == "directory" then
nameValuePair name (dirfn path)
# else if type == "regular" && name != "default.nix" && hasSuffix ".nix" name then
else if type == "regular" && hasSuffix ".nix" name then
nameValuePair (removeSuffix ".nix" name) (fn path)
else
nameValuePair "" null
)
(readDir dir);
mapModules = dir: fn: mapModules' dir fn (path: if pathExists "${path}/default.nix" then (fn path) else null);
mapModulesRec = dir: fn: mapModules' dir fn (path: mapModulesRec path fn);
mapModulesRec' = dir: fn: attrValuesRec (mapModulesRec dir fn);
}

19
lib/nixos.nix Normal file
View File

@ -0,0 +1,19 @@
{ inputs, lib, pkgs, ... }:
let
inherit (lib) mkDefault nixosSystem;
in {
mkHost = system: path:
nixosSystem {
inherit system;
specialArgs = { inherit lib inputs system; };
modules = [
{
nixpkgs.pkgs = pkgs;
networking.hostName = mkDefault (baseNameOf path);
}
../.
(import path)
];
};
}

20
lib/pkgs.nix Normal file
View File

@ -0,0 +1,20 @@
{ pkgs, ... }:
let
inherit (pkgs.stdenv) mkDerivation;
in rec {
_buildBinScript = buildInputs: name: mkDerivation {
inherit name buildInputs;
src = builtins.path { path = ../bin; name = "dotfiles"; };
buildCommand = ''
install -Dm755 $src/${name} $out/bin/${name}
patchShebangs $out/bin/${name}
'';
};
buildBinScript = _buildBinScript [];
buildBabashkaBinScript = _buildBinScript [ pkgs.babashka ];
}

88
lib/utils.nix Normal file
View File

@ -0,0 +1,88 @@
{ lib, ... }:
let
inherit (builtins) attrValues readFile;
inherit (lib) concatStringsSep filterAttrs fold isAttrs mapAttrs' mkOption types;
in rec {
/* Map over attrs with f and then filter them using pred
Type:
mapFilterAttrs ::
(String -> a -> Bool) -> (String -> b -> AttrSet) -> AttrSet' -> AttrSet
where AttrSet' has a value of type b and AttrSet of type a
Example:
mapFilterAttrs (n: v: n == "foo" || v == "bar") (n: v: nameValuePair n v)
{ foo = "baz"; a = "bar"; b = "foo" };
=> { foo = "baz"; a = "bar"; }
*/
mapFilterAttrs = pred: f: attrs: filterAttrs pred (mapAttrs' f attrs);
/* Recursively generates a list of values of attr even for nested attrs
Type:
attrValuesRec :: AttrSet -> [x]
Example:
attrValuesRec { foo = { bar = "baz"; }; a = "b"; }
=> ["baz" "b"]
*/
attrValuesRec = attr: fold (x: xs: (if isAttrs x then attrValuesRec x else [x]) ++ xs) [] (attrValues attr);
/* Filter the self key from the given attr
Type:
filterSelf :: AttrSet -> AttrSet
Example:
filterSelf { foo = "bar"; self = "baz"; }
=> { foo = "bar"; }
*/
filterSelf = attr: filterAttrs (n: _: n != "self") attr;
/* Maps the items of list to strings and concatenates them with sep in
between the individual items
Type:
joinWithSep :: [a] -> String -> String
a should be a type that is convertable to string using toString
Example:
joinWithSep [ 42 "foo" 0 ] "-"
=> "42-foo-0"
*/
joinWithSep = list: sep: concatStringsSep sep (map toString list);
/* Reads the given path and appends the extras to it
Type:
configWithExtras :: Path -> String -> String
Example:
configWithExtras example.txt "Appended text"
=> "Some text from example\nAppended text"
Given that example.txt contains "Some text from example"
*/
configWithExtras = path: extras: "${readFile path}\n${extras}";
enable = { enable = true; };
/* A simplifiation for creating options
Example:
mkOpt types.str "foobar" "A very important option"
=> mkOption {
type = types.str;
default = "foobar";
description = "A very important option";
}
*/
mkOpt = type: default: description:
mkOption { inherit type default description; };
/* Creates option without description */
mkOpt' = type: default: mkOpt type default null;
/* Alias for mkOpt' types.bool */
mkBoolOpt = default: mkOpt' types.bool default;
}

24
modules/agenix.nix Normal file
View File

@ -0,0 +1,24 @@
{ options, lib, inputs, pkgs, config, ... }:
with builtins;
with lib;
with lib._;
let
inherit (inputs) agenix;
secretsDir = "${toString ../hosts}/${config.networking.hostName}/secrets";
secretsFile = "${secretsDir}/secrets.nix";
in {
imports = [ agenix.nixosModules.age ];
environment.systemPackages = [ agenix.defaultPackage.x86_64-linux ];
age = {
secrets = mkIf (pathExists secretsFile) (mapAttrs (n: o: {
file = "${secretsDir}/" + n;
owner = o.owner;
}) (import secretsFile));
identityPaths = options.age.identityPaths.default ++ (filter pathExists [
# ".ssh/id_ed25519"
# ".ssh/id_rsa"
]);
};
}

View File

@ -0,0 +1,45 @@
{ config, options, pkgs, lib, ... }:
with lib;
let
cfg = config.modules.desktop.apps.alacritty;
in {
options.modules.desktop.apps.alacritty = {
enable = mkOption {
type = types.bool;
default = false;
};
executable = mkOption {
type = types.str;
default = "${pkgs.alacritty}/bin/alacritty";
};
};
config = mkIf cfg.enable {
user.packages = with pkgs; [
alacritty
];
home._.programs.alacritty = {
enable = true;
/*
settings = {
background_opacity = theme.backgroundOpacity;
font = {
size = 12;
normal.family = theme.font.mono;
bold.family = theme.font.mono;
italic.family = theme.font.mono;
};
colors = {
primary = {
background = theme.colors.background;
foreground = theme.colors.foreground;
};
normal = theme.colors.backgroundScheme;
bright = theme.colors.foregroundScheme;
};
};
*/
};
};
}

View File

@ -0,0 +1,24 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.modules.desktop.apps.firefox;
wayland = config.modules.desktop.sway.enable;
in {
options.modules.desktop.apps.firefox = {
enable = mkOption {
type = types.bool;
default = trace "penis" false;
};
};
config = mkIf cfg.enable {
/*
user.packages = with pkgs; [
firefox-wayland
# firefox
];
*/
user.packages = abort "sussy balls";
};
}

View File

@ -0,0 +1,20 @@
{ pkgs, config, lib, options, ... }:
with lib;
let
cfg = config.modules.desktop.apps.mpc;
in {
options.modules.desktop.apps.mpc = {
enable = mkOption {
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable {
modules.services.mpd.enable = true;
environment.systemPackages = with pkgs; [
mpc_cli
];
};
}

View File

@ -0,0 +1,19 @@
{ config, options, pkgs, lib, ... }:
with lib;
let
cfg = config.modules.desktop.apps.obs;
in {
options.modules.desktop.apps.obs = {
enable = mkOption {
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
obs-studio
];
};
}

View File

@ -0,0 +1,24 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.modules.desktop.apps.wofi;
in {
options.modules.desktop.apps.wofi = {
enable = mkOption {
type = types.bool;
default = false;
description = "";
};
executable = mkOption {
type = types.str;
default = "${pkgs.wofi}/bin/wofi";
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
wofi
];
};
}

View File

@ -0,0 +1,18 @@
{ config, options, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.desktop;
in {
options.modules.desktop = {
theme = mkOption {
type = types.str;
default = "still";
description = "Sets a particular styling and wallpaper configuration.";
};
};
config = {
services.dbus.enable = true;
};
}

View File

@ -0,0 +1,35 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.modules.desktop.editors.codium;
in {
options.modules.desktop.editors.codium = {
enable = mkOption {
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable {
home._.programs.vscode = {
enable = true;
package = (pkgs.vscode-with-extensions.override {
vscode = pkgs.vscodium;
vscodeExtensions = with pkgs.vscode-extensions; [
ms-vsliveshare.vsliveshare
bbenoist.nix
zhuangtongfa.material-theme
pkief.material-icon-theme
vscodevim.vim
] ++ (if config.modules.dev.haskell.enable then [
haskell.haskell
justusadam.language-haskell
] else [ ]);
}).overrideAttrs (old: {
inherit (pkgs.vscodium) pname version;
});
extensions = [ ];
};
};
}

View File

@ -0,0 +1,53 @@
{ config, inputs, pkgs, lib, options, ... }: