From a123f87b220f0fa70a624447bbe50ed09b6a42ac Mon Sep 17 00:00:00 2001 From: Rachel Lambda Samuelsson Date: Mon, 31 Jul 2023 14:18:02 +0200 Subject: [PATCH] switch to flake based config --- flake.lock | 49 +++++ flake.nix | 32 +++ home/rachel.nix | 188 ++++++++++++++++++ {nixos => lambda}/configuration.nix | 198 +------------------ {nixos => lambda}/hardware-configuration.nix | 0 readme.md | 7 +- 6 files changed, 284 insertions(+), 190 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home/rachel.nix rename {nixos => lambda}/configuration.nix (52%) rename {nixos => lambda}/hardware-configuration.nix (100%) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..dbb0b15 --- /dev/null +++ b/flake.lock @@ -0,0 +1,49 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1687871164, + "narHash": "sha256-bBFlPthuYX322xOlpJvkjUBz0C+MOBjZdDOOJJ+G2jU=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "07c347bb50994691d7b0095f45ebd8838cf6bc38", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.05", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1690630041, + "narHash": "sha256-gbnvqm5goS9DSKAqGFpq3398aOpwejmq4qWikqmQyRo=", + "owner": "NixOs", + "repo": "nixpkgs", + "rev": "d57e8c535d4cbb07f441c30988ce52eec69db7a8", + "type": "github" + }, + "original": { + "owner": "NixOs", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2fa3769 --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +rec { + + description = "My various NixOs configurations"; + + inputs = { + nixpkgs.url = "github:NixOs/nixpkgs/nixos-23.05"; + home-manager.url = "github:nix-community/home-manager/release-23.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, home-manager }: { + + nixosConfigurations.lambda = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + { + nix.registry.nixpkgs.flake = nixpkgs; + system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; + } + ./lambda/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.rachel = import ./home/rachel.nix; + }; + } + ]; + }; + }; +} diff --git a/home/rachel.nix b/home/rachel.nix new file mode 100644 index 0000000..4f1b3ff --- /dev/null +++ b/home/rachel.nix @@ -0,0 +1,188 @@ +{ pkgs, ... }: +let username = "rachel"; + homeDir = "/home/${username}"; + SAX2 = pkgs.fetchurl { + name = "SAX2"; + url = "https://abrudz.github.io/SAX2/SAX2.ttf"; + sha256 = "sha256-DgvDWXO2fnKZNu9EvQOq8GNMTU3PUdp85+/0ZHdRXZc="; + + recursiveHash = true; + + downloadToTemp = true; + postFetch = '' + mkdir -p "$out/share/fonts/truetype" + mv "$downloadedFile" "$out/share/fonts/truetype/SAX2.ttf" + ''; + }; +in +{ + home = { + username = username; + homeDirectory = homeDir; + packages = with pkgs; [ + neofetch + pfetch + unzip + zip + xz + gzip + bzip2 + p7zip + usbutils + pciutils + nettools + nmap + arp-scan + acpi + julia + python3 + ghc + firefox + sxiv + zathura + gnupg + agda + rofi + discord + pinentry_qt + dig + xxd + mpv + zoom-us + slack + imagemagick + ffmpeg + sl + cowsay + lolcat + fortune + banner + yt-dlp + libreoffice + protonmail-bridge + pass + protonvpn-cli + protonvpn-gui + thunderbird + tidal-hifi + signal-desktop + transmission-gtk + xclip + clinfo + glxinfo + vulkan-tools + obs-studio + file + gimp + SAX2 + twemoji-color-font + bat + steam + steam-run + ]; + stateVersion = "23.05"; + }; + + xdg.userDirs = { + enable = true; + createDirectories = true; + desktop = "${homeDir}"; + documents = "${homeDir}/doc"; + download = "${homeDir}/dwn"; + music = "${homeDir}/music"; + pictures = "${homeDir}/img"; + publicShare = "${homeDir}/srv"; + templates = "${homeDir}/doc/templates"; + videos = "${homeDir}/vid"; + }; + + + programs = { + bash = { + enable = true; + enableCompletion = true; + historyFile = "/dev/null"; + sessionVariables = { + PS1 ="\\033[1m\\u\\033[0m@\\033[1m\\h\\033[0m: \\w\nλ "; + BROWSER = "firefox"; + XINITRC = "${homeDir}/bin/xinitrc"; + XAUTHORITY = "${homeDir}/.local/share/Xauthority"; + PASH_KEYID = "3E4A909C8FEF6E3783699C79DFC26EF8EDAD6D71"; + QT_AUTO_SCREEN_FACTOR = 1; + EDITOR = "emacsclient"; + PATH = "${homeDir}/bin:$PATH"; + NIX_SHELL_PRESERVE_PROMPT=1; + }; + shellAliases = { + x = "startx"; + rm = "rm -i"; + cal = "cal -m"; + }; + initExtra = '' + source ~/.profile + set -o vi + [ "$IN_NIX_SHELL" ] && export PS1="''${PS1%λ }❄ " + ''; + }; + + + emacs = { + enable = true; + package = pkgs.emacs-gtk; + extraPackages = epkgs: with epkgs; with melpaStablePackages; [ + magit + nix-mode + julia-repl + julia-mode + lean-mode + proof-general + pdf-tools + dune + tuareg + idris-mode + haskell-emacs-base + multi-vterm + dmenu + markdown-preview-mode + markdown-mode + exwm + org-superstar + org-fragtog + visual-fill + writeroom-mode + haskell-emacs + treemacs-evil + treemacs + solarized-theme + doom-modeline + all-the-icons-dired + page-break-lines + all-the-icons + dashboard + org-evil + zotero + vterm + undo-fu + latex-math-preview + haskell-mode + evil-surround + undo-tree + evil-org + evil + evil-commentary + evil-leader + meow + purescript-mode + ]; + }; + + git = { + enable = true; + userName = "Rachel Lambda Samuelsson"; + userEmail = "depsterr@protonmail.com"; + extraConfig = { + init.defaultBranch = "master"; + }; + }; + }; +} diff --git a/nixos/configuration.nix b/lambda/configuration.nix similarity index 52% rename from nixos/configuration.nix rename to lambda/configuration.nix index 06f4500..5baf754 100644 --- a/nixos/configuration.nix +++ b/lambda/configuration.nix @@ -1,31 +1,17 @@ { config, pkgs, ... }: -let SAX2 = pkgs.fetchurl { - name = "SAX2"; - url = "https://abrudz.github.io/SAX2/SAX2.ttf"; - sha256 = "sha256-DgvDWXO2fnKZNu9EvQOq8GNMTU3PUdp85+/0ZHdRXZc="; - - recursiveHash = true; - - downloadToTemp = true; - postFetch = '' - mkdir -p "$out/share/fonts/truetype" - mv "$downloadedFile" "$out/share/fonts/truetype/SAX2.ttf" - ''; - }; -in -rec { +{ # [HARDWARE] imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ]; hardware.opengl = { enable = true; driSupport = true; driSupport32Bit = true; }; + hardware.bluetooth.enable = true; services.logind = { lidSwitch = "hibernate"; lidSwitchDocked = "ignore"; @@ -187,179 +173,13 @@ rec { # [USER / HOME MANAGER] users.users.rachel = { isNormalUser = true; - extraGroups = [ "wheel" "networkmanager" "video" "input" "audio" "wireshark" ]; - }; - - home-manager.users.rachel = rec { - home = { - username = "rachel"; - homeDirectory = "/home/rachel"; - packages = with pkgs; [ - neofetch - pfetch - unzip - zip - xz - gzip - bzip2 - p7zip - usbutils - pciutils - nettools - nmap - arp-scan - acpi - julia - python3 - ghc - firefox - sxiv - zathura - gnupg - agda - rofi - discord - pinentry_qt - dig - xxd - mpv - zoom-us - slack - imagemagick - ffmpeg - sl - cowsay - lolcat - fortune - banner - yt-dlp - libreoffice - protonmail-bridge - pass - protonvpn-cli - protonvpn-gui - thunderbird - tidal-hifi - signal-desktop - transmission-gtk - xclip - clinfo - glxinfo - vulkan-tools - obs-studio - file - gimp - SAX2 - twemoji-color-font - bat - steam - steam-run - ]; - stateVersion = system.stateVersion; - }; - - xdg.userDirs = { - enable = true; - createDirectories = true; - desktop = "${home.homeDirectory}"; - documents = "${home.homeDirectory}/doc"; - download = "${home.homeDirectory}/dwn"; - music = "${home.homeDirectory}/music"; - pictures = "${home.homeDirectory}/img"; - publicShare = "${home.homeDirectory}/srv"; - templates = "${home.homeDirectory}/doc/templates"; - videos = "${home.homeDirectory}/vid"; - }; - - - programs = { - bash = { - enable = true; - enableCompletion = true; - historyFile = "/dev/null"; - sessionVariables = { - PS1 ="\\033[1m\\u\\033[0m@\\033[1m\\h\\033[0m: \\w\nλ "; - BROWSER = "firefox"; - XINITRC = "${home.homeDirectory}/bin/xinitrc"; - XAUTHORITY = "${home.homeDirectory}/.local/share/Xauthority"; - PASH_KEYID = "3E4A909C8FEF6E3783699C79DFC26EF8EDAD6D71"; - QT_AUTO_SCREEN_FACTOR = 1; - EDITOR = "emacsclient"; - PATH = "${home.homeDirectory}/bin:$PATH"; - NIX_SHELL_PRESERVE_PROMPT=1; - }; - shellAliases = { - x = "startx"; - rm = "rm -i"; - cal = "cal -m"; - }; - initExtra = '' - source ~/.profile - set -o vi - [ "$IN_NIX_SHELL" ] && export PS1="''${PS1%λ }❄ " - ''; - }; - - - emacs = { - enable = true; - package = pkgs.emacs-gtk; - extraPackages = epkgs: with epkgs; with melpaStablePackages; [ - magit - nix-mode - julia-repl - julia-mode - lean-mode - proof-general - pdf-tools - dune - tuareg - idris-mode - haskell-emacs-base - multi-vterm - dmenu - markdown-preview-mode - markdown-mode - exwm - org-superstar - org-fragtog - visual-fill - writeroom-mode - haskell-emacs - treemacs-evil - treemacs - solarized-theme - doom-modeline - all-the-icons-dired - page-break-lines - all-the-icons - dashboard - org-evil - zotero - vterm - undo-fu - latex-math-preview - haskell-mode - evil-surround - undo-tree - evil-org - evil - evil-commentary - evil-leader - meow - purescript-mode - ]; - }; - - git = { - enable = true; - userName = "Rachel Lambda Samuelsson"; - userEmail = "depsterr@protonmail.com"; - extraConfig = { - init.defaultBranch = "master"; - }; - }; - }; + extraGroups = [ + "wheel" + "networkmanager" + "video" + "input" + "audio" + ]; }; # This value determines the NixOS release from which the default diff --git a/nixos/hardware-configuration.nix b/lambda/hardware-configuration.nix similarity index 100% rename from nixos/hardware-configuration.nix rename to lambda/hardware-configuration.nix diff --git a/readme.md b/readme.md index 958f127..c460754 100644 --- a/readme.md +++ b/readme.md @@ -1,2 +1,7 @@ # nix -This is my nixos configuration, once I have multiple machines running nix I'll devise some modular approach with device specific options in different files. I'm also interested in switching to a flakes based configuration at some point. + +My flake-based nixos configuration. + +* `flake.nix`: flake defining configurations +* `home`: contains home-manager user configs +* `lambda`: contains config for laptop