From a642918e5d9df38ee172d37aefe42f40bad80309 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Sat, 11 May 2024 21:31:48 +0200 Subject: good starting point --- configuration.nix | 45 +++++++ flake.lock | 290 +++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 32 +++++ hardware-configuration.nix | 44 +++++++ home.nix | 200 +++++++++++++++++++++++++++++++ wallpapers/thompson.jpg | Bin 0 -> 449295 bytes xmobarrc | 19 +++ xmonad.hs | 95 +++++++++++++++ 8 files changed, 725 insertions(+) create mode 100644 configuration.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hardware-configuration.nix create mode 100644 home.nix create mode 100644 wallpapers/thompson.jpg create mode 100644 xmobarrc create mode 100644 xmonad.hs diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..dedcd96 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,45 @@ +{ + config, + pkgs, + ... +}: { + imports = [./hardware-configuration.nix]; + nix.settings.experimental-features = ["nix-command" "flakes"]; + + boot.loader.grub.device = "/dev/sda"; + time.timeZone = "Europe/Berlin"; + i18n.defaultLocale = "en_US.UTF-8"; + + networking = { + hostName = "hostname"; + networkmanager.enable = true; + }; + + users.users.tom = { + isNormalUser = true; + extraGroups = ["wheel" "networkmanager" "video"]; + shell = pkgs.zsh; + }; + + programs.zsh = { + enable = true; + promptInit = '' + autoload -Uz vcs_info + precmd() { vcs_info } + zstyle ':vcs_info:git:*' formats '|%F{3}%b%f' + setopt PROMPT_SUBST + PROMPT='<%F{2}%n%f@%F{6}%m%f|%F{5}%~%f''${vcs_info_msg_0_}%f> ' + ''; + }; + fonts.packages = [pkgs.hermit]; + services = { + openssh.enable = true; + xserver = { + enable = true; + autorun = false; + displayManager.startx.enable = true; + }; + }; + system.stateVersion = "23.11"; + zramSwap.enable = true; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..57b6460 --- /dev/null +++ b/flake.lock @@ -0,0 +1,290 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706830856, + "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixvim", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713566308, + "narHash": "sha256-7Y91t8pheIzjJveUMAPyeh5NOq5F49Nq4Hl2532QpJs=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "057117a401a34259c9615ce62218aea7afdee4d3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706955260, + "narHash": "sha256-W3y0j77IDVbmbajudHoUr46RpswujUCl+D5Vru53UsI=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "880d9bc2110f7cae59698f715b8ca42cdc53670c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706833576, + "narHash": "sha256-w7BL0EWRts+nD1lbLECIuz6fRzmmV+z8oWwoY7womR0=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "bdbae6ecff8fcc322bf6b9053c0b984912378af7", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1713537308, + "narHash": "sha256-XtTSSIB2DA6tOv+l0FhvfDMiyCmhoRbNB+0SeInZkbk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5c24cf2f0a12ad855f444c30b2421d044120c66f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1707268954, + "narHash": "sha256-2en1kvde3cJVc3ZnTy8QeD2oKcseLFjYPLKhIGDanQ0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f8e2ebd66d097614d51a56a755450d4ae1632df1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1706732774, + "narHash": "sha256-hqJlyJk4MRpcItGYMF+3uHe8HvxNETWvlGtLuVpqLU0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b8b232ae7b8b144397fdb12d20f592e5e7c1a64d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "nixpkgs": "nixpkgs_2", + "nixvim": "nixvim_2" + }, + "locked": { + "lastModified": 1707655307, + "narHash": "sha256-y/mtftc0RHEwxKSkbsC7/1wTRP4FylEqUncyVTijh1A=", + "ref": "refs/heads/master", + "rev": "69e9543d31c81419ed9a1c5c51c220480289aaa0", + "revCount": 3, + "type": "git", + "url": "https://git.tombarrett.xyz/nixvim" + }, + "original": { + "type": "git", + "url": "https://git.tombarrett.xyz/nixvim" + } + }, + "nixvim_2": { + "inputs": { + "flake-parts": "flake-parts", + "home-manager": "home-manager_2", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs_3", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1707474531, + "narHash": "sha256-XoWqoTIdGpDYkHXTCmUNb7AxbBzDtpKmZIisnxt7nDQ=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "3bbb3d5453e69f868da7549d19bbdb5a2a49efb2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706424699, + "narHash": "sha256-Q3RBuOpZNH2eFA1e+IHgZLAOqDD9SKhJ/sszrL8bQD4=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "7c54e08a689b53c8a1e5d70169f2ec9e2a68ffaf", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..361a52c --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixvim.url = "git+https://git.tombarrett.xyz/nixvim"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + outputs = { + home-manager, + nixpkgs, + nixvim, + self, + }: { + nixosConfigurations."hostname" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./configuration.nix + home-manager.nixosModules.home-manager + { + home-manager = { + extraSpecialArgs = {inherit nixvim;}; + useGlobalPkgs = true; + users.tom = import ./home.nix; + useUserPackages = true; + }; + } + ]; + }; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..a09ff30 --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,44 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = ["ehci_pci" "ahci" "sd_mod" "sr_mod" "sdhci_pci"]; + boot.initrd.kernelModules = []; + boot.kernelModules = ["kvm-intel"]; + boot.extraModulePackages = []; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/4a58083f-189f-41ff-a437-b4b78b04c686"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."root".device = "/dev/disk/by-uuid/f49dd6de-e376-47c8-8ed0-f5107317e090"; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/a26d8cfa-5b0e-43a2-9873-329c0488f748"; + fsType = "ext4"; + }; + + swapDevices = []; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp0s25.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..6bbe0fb --- /dev/null +++ b/home.nix @@ -0,0 +1,200 @@ +{ + config, + lib, + nixvim, + pkgs, + ... +}: let + vars = { + BEMENU_OPTS = + "--fn 'Hermit 12' --line-height 25 " + + "--hb #a1b56c --hf #f8f8f8 --nf #b8b8b8 --af #b8b8b8 " + + "--tf #f8f8f8 --fbf #f8f8f8 --ff #f8f8f8 --cf #f8f8f8 " + + "--sf #f8f8f8 --scf #f8f8f8 --hp 10"; + }; +in { + home = { + username = "tom"; + homeDirectory = "/home/tom"; + stateVersion = "23.11"; + packages = with pkgs; [ + acpi + binutils + bemenu + feh + file + ghc + gimp + haskellPackages.fourmolu + htop + ncmpcpp + nixvim.packages.x86_64-linux.default + tmux + tree + vim + xmobar + ]; + sessionVariables = + vars + // { + LESS = "-R"; + EDITOR = "vim"; + }; + + file.".xinitrc".text = '' + xmonad + ''; + # todo find better solution for + # restarting without nixos switch + file.".config/xmonad/xmonad.hs".source = + config.lib.file.mkOutOfStoreSymlink + "${config.home.homeDirectory}/src/nixos/xmonad.hs"; + file.".xmobarrc".source = + config.lib.file.mkOutOfStoreSymlink + "${config.home.homeDirectory}/src/nixos/xmobarrc"; + }; + programs = { + home-manager.enable = true; + alacritty = { + enable = true; + settings = { + font = { + bold.family = "Hermit"; + bold_italic.family = "Hermit"; + italic.family = "Hermit"; + normal.family = "Hermit"; + size = 10; + }; + keyboard.bindings = [ + { + key = "="; + mods = "ALT"; + action = "IncreaseFontSize"; + } + { + key = "-"; + mods = "ALT"; + action = "DecreaseFontSize"; + } + ]; + }; + }; + firefox = { + enable = true; + profiles.tom = { + search = { + default = "DuckDuckGo"; + force = true; + }; + bookmarks = [ + { + toolbar = true; + bookmarks = [ + { + name = "home-manager"; + url = "https://nix-community.github.io/home-manager/options.xhtml"; + } + { + name = "nixpkgs"; + url = "https://search.nixos.org/packages"; + } + ]; + } + ]; + settings = { + "browser.startup.homepage" = "https://duckduckgo.com"; + "browser.newtabpage.enabled" = false; + "browser.toolbars.bookmarks.visibility" = "always"; + "extensions.activeThemeID" = "firefox-compact-dark@mozilla.org"; + "general.autoScroll" = true; + "browser.bookmarks.addedImportButton" = true; + "browser.uiCustomization.state" = { + "placements" = { + "widget-overflow-fixed-list" = []; + "unified-extensions-area" = []; + "nav-bar" = [ + "back-button" + "forward-button" + "stop-reload-button" + "urlbar-container" + "downloads-button" + "unified-extensions-button" + ]; + "toolbar-menubar" = ["menubar-items"]; + "TabsToolbar" = ["tabbrowser-tabs" "new-tab-button" "alltabs-button"]; + "PersonalToolbar" = ["personal-bookmarks"]; + }; + "seen" = ["save-to-pocket-button" "developer-button"]; + "dirtyAreaCache" = ["nav-bar" "PersonalToolbar" "toolbar-menubar" "TabsToolbar"]; + "currentVersion" = 20; + "newElementCount" = 3; + }; + "privacy.sanitize.sanitizeOnShutdown" = true; + "privacy.clearOnShutdown.cookies" = true; + "privacy.clearOnShutdown.cache" = true; + "privacy.clearOnShutdown.downloads" = true; + "privacy.clearOnShutdown.history" = true; + "privacy.clearOnShutdown.formData" = true; + "privacy.clearOnShutdown.offlineApps" = true; + "privacy.clearOnShutdown.sessions" = true; + "privacy.clearOnShutdown.siteSettings" = true; + }; + }; + }; + git = { + enable = true; + userName = "tom barrett"; + userEmail = "tom@tombarrett.xyz"; + extraConfig = { + init.defaultBranch = "master"; + }; + }; + gpg.enable = true; + password-store = { + enable = true; + package = pkgs.pass.withExtensions (exts: [exts.pass-otp]); + }; + zsh = { + enable = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + autocd = true; + }; + }; + systemd.user.settings.Manager.DefaultEnvironment = vars; + xsession.windowManager.xmonad = { + enable = true; + enableContribAndExtras = true; + }; + services = { + xscreensaver = { + enable = true; + settings = { + mode = "blank"; + }; + }; + gpg-agent = { + enable = true; + enableSshSupport = true; + pinentryPackage = pkgs.pinentry-bemenu; + # from gpg --list-secret-keys --with-keygrip ([A] keygrip) + sshKeys = []; + }; + }; + xdg.userDirs = { + enable = true; + extraConfig = let + downloads = "${config.home.homeDirectory}/downloads"; + in { + XDG_DESKTOP_DIR = downloads; + XDG_DOCUMENTS_DIR = downloads; + XDG_DOWNLOAD_DIR = downloads; + XDG_MISC_DIR = downloads; + XDG_MUSIC_DIR = downloads; + XDG_PICTURES_DIR = downloads; + XDG_PUBLICSHARE_DIR = downloads; + XDG_TEMPLATES_DIR = downloads; + XDG_VIDEOS_DIR = downloads; + }; + }; +} diff --git a/wallpapers/thompson.jpg b/wallpapers/thompson.jpg new file mode 100644 index 0000000..b3f32cb Binary files /dev/null and b/wallpapers/thompson.jpg differ diff --git a/xmobarrc b/xmobarrc new file mode 100644 index 0000000..7bd4c08 --- /dev/null +++ b/xmobarrc @@ -0,0 +1,19 @@ +Config + { font = "Hermit 13" + , textOffset = 0 + , borderWidth = 0 + , position = TopH 25 + , bgColor = "#a1b56c" + , fgColor = "#b8b8b8" + , commands = + [ Run Date "%a %d %b %Y %H:%M:%S" "date" 10 + , Run DiskU [("/", "")] ["-L", "1"] 50 + , Run Battery ["-t", "%"] 10 + , Run Cpu ["-t", "%"] 10 + , Run Com "sh" ["-c", "ip -br -4 a | awk '!/lo/ {if ($3) printf $3 }'"] "" 10 + , Run XMonadLog + ] + , sepChar = "%" + , alignSep = "}{" + , template = "%XMonadLog% }{ %sh% | %cpu% | %disku% | %battery% | %date% " + } diff --git a/xmonad.hs b/xmonad.hs new file mode 100644 index 0000000..63ce88b --- /dev/null +++ b/xmonad.hs @@ -0,0 +1,95 @@ +import System.Exit +import XMonad +import XMonad.Actions.CycleWS +import XMonad.Hooks.EwmhDesktops +import XMonad.Hooks.StatusBar +import XMonad.Hooks.StatusBar.PP +import XMonad.Layout.Renamed +import XMonad.Layout.Spacing +import XMonad.Prompt +import XMonad.Prompt.FuzzyMatch +import XMonad.Prompt.Pass +import qualified XMonad.StackSet as W +import XMonad.Util.EZConfig +import XMonad.Util.SpawnOnce + +primary = "#a1b56c" +grey0 = "#181818" +grey1 = "#585858" +grey2 = "#b8b8b8" +grey3 = "#f8f8f8" + +main :: IO () +main = + xmonad + . ewmhFullscreen + . ewmh + . withEasySB + ( statusBarProp + "xmobar" + ( pure + def + { ppSep = "" + , ppWsSep = "" + , ppHiddenNoWindows = xmobarColor grey2 grey0 . pad + , ppCurrent = xmobarColor grey3 primary . pad + , ppHidden = xmobarBorder "Top" primary 2 . xmobarColor grey2 grey0 . pad + , ppTitle = const "" + , ppLayout = xmobarColor grey2 grey0 . pad + } + ) + ) + defToggleStrutsKey + $ let promptConfig = + def + { position = Top + , bgColor = grey0 + , bgHLight = primary + , promptBorderWidth = 0 + , fgHLight = grey3 + , height = 25 + , font = "xft:Hermit:size=12" + , searchPredicate = fuzzyMatch + , sorter = fuzzySort + , alwaysHighlight = True + } + in def + { borderWidth = 2 + , layoutHook = + renamed + [Replace "[]="] + (spacingWithEdge 8 $ Tall 1 (5 / 100) (1 / 3)) + ||| renamed [Replace "[M]"] Full + , normalBorderColor = grey1 + , focusedBorderColor = primary + , keys = \c -> + mkKeymap c $ + [ ("M-", spawn "alacritty") + , ("M-q", kill) + , ("M-d", spawn $ "bemenu-run -p ' ' --cw 2") + , ("M-r", spawn "xmonad --recompile && xmonad --restart") + , ("M-S-e", io exitSuccess) + , ("M-j", windows W.focusDown) + , ("M-k", windows W.focusUp) + , ("M-c", passPrompt promptConfig) + , ("M-x", passOTPPrompt promptConfig) + , ("M-i", sendMessage $ IncMasterN 1) + , ("M-u", sendMessage $ IncMasterN $ -1) + , ("M-h", sendMessage Shrink) + , ("M-l", sendMessage Expand) + , ("M-m", sendMessage $ JumpToLayout "[M]") + , ("M-t", sendMessage $ JumpToLayout "[]=") + , ("M-", toggleWS) + , ("M-S-", windows W.swapMaster) + , ("M-S-", withFocused $ windows . W.sink) + ] + ++ concatMap + ( \n -> + [ ("M-" ++ n, windows $ W.greedyView n) + , ("M-S-" ++ n, windows $ W.shift n) + ] + ) + (map show [1 .. 9]) + , startupHook = do + spawnOnce "feh --bg-fill --no-fehbg --randomize /home/tom/src/nixos/wallpapers" + } -- cgit v1.2.3