diff --git a/check-restart.sh b/check-restart.sh new file mode 100755 index 0000000..b4dee7d --- /dev/null +++ b/check-restart.sh @@ -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.."; +} diff --git a/configs/default.nix b/configs/default.nix new file mode 100644 index 0000000..0ea69c2 --- /dev/null +++ b/configs/default.nix @@ -0,0 +1,5 @@ +{ ... }: { + imports = [ + ./git.nix + ]; +} diff --git a/configs/git.nix b/configs/git.nix new file mode 100644 index 0000000..7aa5fae --- /dev/null +++ b/configs/git.nix @@ -0,0 +1,18 @@ +{ + programs.git = { + enable = true; + config = [ + { + user = { + name = "Kyle Isom"; + email = "kyle@imap.cc"; + }; + init = { + defaultBranch = "master"; + } + } + + { push = { default = "current"; }; } + ]; + }; +} diff --git a/configuration.nix b/configuration.nix index 1b14f9e..918135b 100644 --- a/configuration.nix +++ b/configuration.nix @@ -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 :tag - nnoremap :pop - - nnoremap :bprev - - " fix glitches in certain terminals - " backspace - imap ^? ^H - - " f7 toggles spelling on/off - nn :setlocal spell! spell? - - " view binary files as hex - " Convert to hex and back; does not save changes - nn :%!xxd -g 1 - nn :%!xxd -g 1 -r - - " makefile magic - " compiler stuff - let g:compiler_gcc_ignore_unmatched_lines=1 - let mapleader=',' - " quickfix :make - nmap m :wa:silent! make \| redraw! \| cw - vmap m :wa:silent! make \| redraw! \| cw - nn ,c :silent! make clean \| redraw! \| cw - " handy shortcuts - map h :ccl - map s :cw - map l :cl - " jump between messages - map n :cn - map p :cp - - " format selection - map f :!fmt - - - " @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 o :NERDTree - - " FZF - nmap (fzf-maps-n) - xmap (fzf-maps-x) - omap (fzf-maps-o) - imap (fzf-complete-word) - imap (fzf-complete-path) - imap (fzf-complete-file-ag) - imap (fzf-complete-line) - - command! FZFBuffers call fzf#run({'source': map(range(1, bufnr('$')), 'bufname(v:val)'), 'sink': 'e', 'down': '30%'}) - map b :FZFBuffers - - " Ack - if executable('ag') - let g:ackprg = 'ag --vimgrep' - endif - - " The space is signficant. - map / :Ack - - " Go stuff - map i :GoImports - map i :GoImports - - let g:go_fmt_autosave = 1 - let g:go_fmt_command = "goimports" - - au FileType rust nmap gd (rust-def) - autocmd Filetype c,cpp inoremap t :wa:silent! make test \| redraw! \| cw - autocmd Filetype go map t :wa:GoTest - autocmd Filetype go map C-] :w:GoDef - autocmd Filetype go map C-\ :w:GoDefPop - - - 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,16 +70,23 @@ 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; - wayland = false; + windowManager = { + i3.enable = true; + }; + xkb = { + layout = "us"; + options = "ctrl:swapcaps"; + }; }; # from a previous platform, but might be similar. @@ -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. It‘s 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; }