updating from jeremy's nix config

This commit is contained in:
Kyle Isom 2025-04-11 13:29:01 -07:00
parent 56a13f4932
commit eb76502381
4 changed files with 99 additions and 339 deletions

18
check-restart.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
my @booted = split("/", `readlink -f /run/booted-system/kernel`);
my @current = split("/", `readlink -f /run/current-system/kernel`);
if ($booted[3] ne $current[3]) {
say "Restart required!";
say "old: $booted[3]";
say "new: $current[3]";
exit 1;
} else {
say "system is clean..";
}

5
configs/default.nix Normal file
View File

@ -0,0 +1,5 @@
{ ... }: {
imports = [
./git.nix
];
}

18
configs/git.nix Normal file
View File

@ -0,0 +1,18 @@
{
programs.git = {
enable = true;
config = [
{
user = {
name = "Kyle Isom";
email = "kyle@imap.cc";
};
init = {
defaultBranch = "master";
}
}
{ push = { default = "current"; }; }
];
};
}

View File

@ -1,337 +1,21 @@
{ config, pkgs, lib, ... }:
let
emScript = pkgs.writeScriptBin "em" ''
#!/usr/bin/env zsh
if [ -z "$DISPLAY" ]
then
NW=""
else
NW="-n"
fi
if [ -z "$@" ]
then
cd $HOME
fi
emacsclient $NW -c -a "" "$@"
'';
home-manager = builtins.fetchGit {
url = "https://github.com/nix-community/home-manager.git";
ref = "master";
};
pubKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINYpsgH3ltPvS3E0LE1IRpp5cJzKU4usv+OlCxnLXRfo kyle@hephaestus"
];
userBase = {
shell = pkgs.zsh;
openssh.authorizedKeys.keys = pubKeys;
};
homeBase = {
programs.git = {
enable = true;
lfs.enable = true;
userName = "K. Isom";
userEmail = "kyle@imap.cc";
aliases = {
log = "log --color=never";
};
extraConfig = {
color = {
branch = false;
diff = true;
interactive = false;
log = false;
status = false;
ui = false;
};
push = {
default = "simple";
};
transfer = {
fsckobjects = true;
};
fetch = {
fsckobjects = true;
};
sendemail = {
smtpserver = "mail.messagingengine.com";
smtpuser = "kyle@imap.cc";
smtpAuth = "PLAIN";
smtpEncryption = "tls";
smtpserverport = 587;
cc = "${homeBase.programs.git.userEmail}";
confirm = "auto";
};
};
};
programs.firefox = {
enable = true;
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
ublock-origin
bitwarden
];
profiles = {
default = {
settings = {
"app.normandy.enabled" = false;
"app.shield.optoutstudies.enabled" = false;
"app.update.auto" = false;
"apz.peek_messages.enabled" = false;
"browser.aboutConfig.showWarning" = false;
"browser.bookmarks.showMobileBookmarks" = true;
"browser.ctrlTab.recentlyUsedOrder" = false;
"browser.messaging-system.whatsNewPanel.enabled" = false;
"browser.newtabpage.activity-stream.asrouter.providers.snippets" = "{}";
"browser.newtabpage.activity-stream.feeds.section.highlights" = false;
"browser.newtabpage.activity-stream.feeds.snippets" = false;
"browser.newtabpage.activity-stream.feeds.system.topsites" = false;
"browser.newtabpage.activity-stream.feeds.system.topstories" = false;
"browser.newtabpage.activity-stream.feeds.telemetry" = false;
"browser.newtabpage.activity-stream.feeds.topsites" = false;
"browser.newtabpage.activity-stream.section.highlights.includePocket" = false;
"browser.newtabpage.enabled" = false;
"browser.proton.enabled" = true;
"browser.safebrowsing.enabled" = false;
"browser.safebrowsing.malware.enabled" = false;
"browser.search.update" = false;
"browser.startup.homepage" = "about:blank";
"browser.tabs.warnOnClose" = false;
"browser.urlbar.placeholderName" = "DuckDuckGo";
"browser.urlbar.suggest.topsites" = false;
"browser.urlbar.update1" = true;
"distribution.searchplugins.defaultLocale" = "en-US";
"extensions.getAddons.search.browseURL" = " https://addons.mozilla.org/%LOCALE%/firefox/search?q=%TERMS%";
"extensions.htmlaboutaddons.recommendations.enabled" = false;
"extensions.pocket.api" = "localhost";
"extensions.pocket.enabled" = false;
"extensions.pocket.oAuthConsumerKey" = "butts";
"extensions.pocket.site" = "localhost";
"general.useragent.locale" = "en-US";
"geo.enabled" = false;
"identity.fxaccounts.account.device.name" = config.networking.hostName;
"media.autoplay.default" = 1;
"media.navigator.enabled" = false;
"network.trr.mode" = 5;
"privacy.firstparty.isolate" = true;
"privacy.resistFingerprinting" = true;
"privacy.trackingprotection.cryptomining.enabled" = true;
"privacy.trackingprotection.enabled" = true;
"privacy.trackingprotection.fingerprinting.enabled" = true;
"privacy.trackingprotection.socialtracking.annotate.enabled" = true;
"privacy.trackingprotection.socialtracking.enabled" = true;
"reader.color_scheme" = "sepia";
"services.sync.declinedEngines" = "addons,passwords,prefs";
"services.sync.engine.addons" = false;
"services.sync.engine.passwords" = false;
"services.sync.engine.prefs" = false;
"services.sync.engineStatusChanged.addons" = true;
"services.sync.engineStatusChanged.prefs" = true;
"signon.rememberSignons" = false;
};
};
};
};
programs.zsh = {
enable = true;
shellAliases = {
vi = "nvim";
};
initExtra = ''
export PATH=$HOME/bin:$HOME/.local/bin:$PATH
export GOPATH=$HOME
'';
};
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
programs.neovim = {
enable = true;
extraConfig = ''
set backspace=indent,eol,start
set cindent autoindent
set confirm
set encoding=utf-8
set incsearch
set hidden
set mouse=a
set nocompatible
set noexpandtab
set nohlsearch
set number
set ruler
set showcmd
set showmatch
set showmode
set tags=./tags,tags,/usr/src/sys/arch/amd64/tags,/var/db/libc.tags
set t_Co=256
set ttyfast
source /usr/share/vim/vim81/ftplugin/man.vim
filetype plugin on
nnoremap <C-N> :tag<CR>
nnoremap <C-P> :pop<CR>
nnoremap <C-P> :bprev<CR>
" fix glitches in certain terminals
" backspace
imap ^? ^H
" f7 toggles spelling on/off
nn <F7> :setlocal spell! spell?<CR>
" view binary files as hex
" Convert to hex and back; does not save changes
nn <F5> :%!xxd -g 1<CR>
nn <F6> :%!xxd -g 1 -r<CR>
" makefile magic
" compiler stuff
let g:compiler_gcc_ignore_unmatched_lines=1
let mapleader=','
" quickfix :make
nmap <silent> <Leader>m :wa<CR>:silent! make \| redraw! \| cw<CR><CR>
vmap <silent> <Leader>m :wa<CR>:silent! make \| redraw! \| cw<CR><CR>
nn ,c :silent! make clean \| redraw! \| cw<CR><CR>
" handy shortcuts
map <Leader>h :ccl<CR>
map <Leader>s :cw<CR>
map <Leader>l :cl<CR>
" jump between messages
map <Leader>n :cn<CR>
map <Leader>p :cp<CR>
" format selection
map <Leader>f :!fmt<CR>
" @c comment, @u uncomment, @p print function name
let @u='0xx$xx^['
let @c='I/*^[A*/^['
let @p='ofprintf(stderr, "%s\n", __func__);^['
:ab #d #define
:ab #i #include
autocmd FileType make setlocal noexpandtab
autocmd FileType c setlocal noexpandtab
autocmd FileType cc setlocal noexpandtab
autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType ada setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=3
" Plugins
" Initialization
call plug#begin('~/.vim/bundle')
Plug 'scrooloose/nerdtree'
Plug 'junegunn/fzf'
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'ambv/black', { 'for': 'python' }
Plug 'mileszs/ack.vim'
Plug 'racer-rust/vim-racer', { 'for': 'rust' }
" Themes
Plug 'KKPMW/oldbook-vim'
Plug 'agreco/vim-citylights'
Plug 'xdefrag/vim-beelzebub'
Plug 'logico-dev/typewriter'
Plug 'vim-scripts/wombat256.vim'
call plug#end()
" NERDTree
map <Leader>o :NERDTree<CR>
" FZF
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
command! FZFBuffers call fzf#run({'source': map(range(1, bufnr('$')), 'bufname(v:val)'), 'sink': 'e', 'down': '30%'})
map <Leader>b :FZFBuffers<CR>
" Ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" The space is signficant.
map <Leader>/ :Ack
" Go stuff
map <Leader>i :GoImports<CR>
map <Leader>i :GoImports<CR>
let g:go_fmt_autosave = 1
let g:go_fmt_command = "goimports"
au FileType rust nmap gd <Plug>(rust-def)
autocmd Filetype c,cpp inoremap <buffer> <Leader>t :wa<CR>:silent! make test \| redraw! \| cw<CR><CR>
autocmd Filetype go map <buffer> <Leader>t :wa<CR>:GoTest<CR>
autocmd Filetype go map <buffer> C-] :w<CR>:GoDef<CR>
autocmd Filetype go map <buffer> C-\ :w<CR>:GoDefPop<CR>
colorscheme oldbook
'';
};
programs.emacs = {
enable = true;
extraPackages = epkgs: [
epkgs.nix-mode
epkgs.magit
epkgs.org
];
};
};
in
{
# this allows you to access `pkgsUnstable` anywhere in your config
_module.args.pkgsUnstable = import inputs.nixpkgs-unstable {
inherit (pkgs.stdenv.hostPlatform) system;
inherit (config.nixpkgs) config;
};
imports =
[
./hardware-configuration.nix
(import "${home-manager}/nixos")
./configs
];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "nodev";
boot.loader.grub.efiSupport = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.luks.devices = {
luksroot = {
name = "luksroot";
device = "/dev/nvme0n1p2";
preLVM = true;
allowDiscards = true;
};
};
boot.kernelPackages = pkgs.linuxPackages_latest;
nix.autoOptimiseStore = true;
nix.gc = {
@ -341,11 +25,24 @@ in
};
time.timeZone = "America/Los_Angeles";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
networking.hostName = "imladris";
networking.networkmanager.enable = true;
networking.useDHCP = false;
networking.interfaces.wlp2s0.useDHCP = true;
services.resolved.enable = true;
services.resolved.fallbackDns = [
"1.1.1.1"
@ -373,17 +70,24 @@ in
services.cron.enable = true;
i18n.defaultLocale = "en_US.UTF-8";
services.xserver.enable = true;
# services.xserver.desktopManager.mate.enable = true;
# Enable the X11 windowing system.
# services.xserver.windowManager.stumpwm.enable = true;
services.xserver.windowManager.i3.enable = true;
services.xserver.displayManager.gdm = {
services.xserver = {
displayManager = {
gdm = {
enable = true;
wayland = false;
};
};
enable = true;
windowManager = {
i3.enable = true;
};
xkb = {
layout = "us";
options = "ctrl:swapcaps";
};
};
# from a previous platform, but might be similar.
# icarus is an "AMD Ryzen 5 PRO 4650U with Radeon Graphics" machine.
@ -398,14 +102,19 @@ in
# Option "TearFree" "true"
# '';
services.xserver.libinput.enable = true;
services.xserver.xkbOptions = "ctrl:swapcaps";
# Enable touchpad support (enabled default in most desktopManager).
services.libinput = {
enable = true;
mouse.naturalScrolling = true;
touchpad.naturalScrolling = true;
};
console.useXkbConfig = true;
sound.enable = true;
hardware.pulseaudio.enable = true;
users.users.kyle = userBase // {
users.users.kyle = {
isNormalUser = true;
extraGroups = [
"wheel"
@ -413,6 +122,17 @@ in
"dialout"
];
};
programs.direnv.enable = true;
programs.command-not-found.enable = false;
# fwupd
services.fwupd.enable = true;
programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [
# Add any missing dynamic libraries for unpackaged programs
# here, NOT in environment.systemPackages
];
# List packages installed in system profile. To search, run:
# $ nix search wget
@ -506,6 +226,8 @@ in
};
programs.zsh.enable = true;
nix.settings.experimental-features = [ "nix-command" ];
# 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
@ -513,7 +235,4 @@ in
# 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 = "20.09"; # Did you read the comment?
home-manager.users.root = homeBase;
home-manager.users.kyle = homeBase;
}