From 1483a5c46ae392239c10294df0d4c79033c81e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Thu, 26 Dec 2024 12:32:58 +0100 Subject: [PATCH] Add nixos configuration and build script --- nixos/flake.lock | 600 ++++++++++++++++++++++++++++++++++ nixos/flake.nix | 22 ++ nixos/nixos/configuration.nix | 146 +++++++++ nixos/rebuild.sh | 2 + 4 files changed, 770 insertions(+) create mode 100644 nixos/flake.lock create mode 100644 nixos/flake.nix create mode 100644 nixos/nixos/configuration.nix create mode 100755 nixos/rebuild.sh diff --git a/nixos/flake.lock b/nixos/flake.lock new file mode 100644 index 0000000..257f94d --- /dev/null +++ b/nixos/flake.lock @@ -0,0 +1,600 @@ +{ + "nodes": { + "aquamarine": { + "inputs": { + "hyprutils": [ + "xremap-flake", + "hyprland", + "hyprutils" + ], + "hyprwayland-scanner": [ + "xremap-flake", + "hyprland", + "hyprwayland-scanner" + ], + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1729527199, + "narHash": "sha256-D5/YksfRga8Akd04ZtIkuYSIOjXVrAzQIQBSeplokzU=", + "owner": "hyprwm", + "repo": "aquamarine", + "rev": "8d732fa8aff8b12ef2b1e2f00fc8153e41312b72", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "aquamarine", + "type": "github" + } + }, + "crane": { + "locked": { + "lastModified": 1729741221, + "narHash": "sha256-8AHZZXs1lFkERfBY0C8cZGElSo33D/et7NKEpLRmvzo=", + "owner": "ipetkov", + "repo": "crane", + "rev": "f235b656ee5b2bfd6d94c3bfd67896a575d4a6ed", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "devshell": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1728330715, + "narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=", + "owner": "numtide", + "repo": "devshell", + "rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "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": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "xremap-flake", + "hyprland", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1729864948, + "narHash": "sha256-CeGSqbN6S8JmzYJX/HqZjr7dMGlvHLLnJJarwB45lPs=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "0c0268a3c80d30b989d0aadbd65f38d4fa27a9a0", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "hyprcursor": { + "inputs": { + "hyprlang": [ + "xremap-flake", + "hyprland", + "hyprlang" + ], + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1728669738, + "narHash": "sha256-EDNAU9AYcx8OupUzbTbWE1d3HYdeG0wO6Msg3iL1muk=", + "owner": "hyprwm", + "repo": "hyprcursor", + "rev": "0264e698149fcb857a66a53018157b41f8d97bb0", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprcursor", + "type": "github" + } + }, + "hyprland": { + "inputs": { + "aquamarine": "aquamarine", + "hyprcursor": "hyprcursor", + "hyprland-protocols": "hyprland-protocols", + "hyprlang": "hyprlang", + "hyprutils": "hyprutils", + "hyprwayland-scanner": "hyprwayland-scanner", + "nixpkgs": "nixpkgs_4", + "pre-commit-hooks": "pre-commit-hooks", + "systems": "systems", + "xdph": "xdph" + }, + "locked": { + "lastModified": 1729852008, + "narHash": "sha256-h9pvIoeWrwyWSIgGO3bEaX9VG8vduH5hBKci9ecHbPs=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "f0e023bff2f2a25ffe5ed3166f55f7274d17c6bc", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "Hyprland", + "type": "github" + } + }, + "hyprland-protocols": { + "inputs": { + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1728345020, + "narHash": "sha256-xGbkc7U/Roe0/Cv3iKlzijIaFBNguasI31ynL2IlEoM=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "a7c183800e74f337753de186522b9017a07a8cee", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, + "hyprlang": { + "inputs": { + "hyprutils": [ + "xremap-flake", + "hyprland", + "hyprutils" + ], + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1728168612, + "narHash": "sha256-AnB1KfiXINmuiW7BALYrKqcjCnsLZPifhb/7BsfPbns=", + "owner": "hyprwm", + "repo": "hyprlang", + "rev": "f054f2e44d6a0b74607a6bc0f52dba337a3db38e", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprlang", + "type": "github" + } + }, + "hyprutils": { + "inputs": { + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1728941256, + "narHash": "sha256-WRypmcZ2Bw94lLmcmxYokVOHPJSZ7T06V49QZ4tkZeQ=", + "owner": "hyprwm", + "repo": "hyprutils", + "rev": "fd4be8b9ca932f7384e454bcd923c5451ef2aa85", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprutils", + "type": "github" + } + }, + "hyprwayland-scanner": { + "inputs": { + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1726874836, + "narHash": "sha256-VKR0sf0PSNCB0wPHVKSAn41mCNVCnegWmgkrneKDhHM=", + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "rev": "500c81a9e1a76760371049a8d99e008ea77aa59e", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1734875076, + "narHash": "sha256-Pzyb+YNG5u3zP79zoi8HXYMs15Q5dfjDgwCdUI5B0nY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1807c2b91223227ad5599d7067a61665c52d1295", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1727825735, + "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1722073938, + "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1729256560, + "narHash": "sha256-/uilDXvCIEs3C9l73JTACm4quuHUsIHcns1c+cHUJwA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4c2fcb090b1f3e5b47eaa7bd33913b574a11e0a0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1729413321, + "narHash": "sha256-I4tuhRpZFa6Fu6dcH9Dlo5LlH17peT79vx1y1SpeKt0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1997e4aa514312c1af7e2bda7fad1644e778ff26", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1729850857, + "narHash": "sha256-WvLXzNNnnw+qpFOmgaM3JUlNEH+T4s22b5i2oyyCpXE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "41dea55321e5a999b17033296ac05fe8a8b5a257", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { + "locked": { + "lastModified": 1726871744, + "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1729104314, + "narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "xremap-flake": "xremap-flake" + } + }, + "systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_6" + }, + "locked": { + "lastModified": 1729613947, + "narHash": "sha256-XGOvuIPW1XRfPgHtGYXd5MAmJzZtOuwlfKDgxX5KT3s=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "aac86347fb5063960eccb19493e0cadcdb4205ca", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "xdph": { + "inputs": { + "hyprland-protocols": [ + "xremap-flake", + "hyprland", + "hyprland-protocols" + ], + "hyprlang": [ + "xremap-flake", + "hyprland", + "hyprlang" + ], + "hyprutils": [ + "xremap-flake", + "hyprland", + "hyprutils" + ], + "hyprwayland-scanner": [ + "xremap-flake", + "hyprland", + "hyprwayland-scanner" + ], + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1728166987, + "narHash": "sha256-w6dVTguAn9zJ+7aPOhBQgDz8bn6YZ7b56cY8Kg5HJRI=", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "rev": "fb9c8d665af0588bb087f97d0f673ddf0d501787", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "type": "github" + } + }, + "xremap": { + "flake": false, + "locked": { + "lastModified": 1729699416, + "narHash": "sha256-UMcyT3CradQsshYTnqUrkrusF+7aUcxHQQm7DGhHEVg=", + "owner": "k0kubun", + "repo": "xremap", + "rev": "a870c1ffeadec63da67372355ed417cfbe2f5a3d", + "type": "github" + }, + "original": { + "owner": "k0kubun", + "ref": "v0.10.2", + "repo": "xremap", + "type": "github" + } + }, + "xremap-flake": { + "inputs": { + "crane": "crane", + "devshell": "devshell", + "flake-parts": "flake-parts", + "home-manager": "home-manager", + "hyprland": "hyprland", + "nixpkgs": "nixpkgs_5", + "treefmt-nix": "treefmt-nix", + "xremap": "xremap" + }, + "locked": { + "lastModified": 1729871870, + "narHash": "sha256-4wvalt4AYgxZpDD2JUiUVsXFexYtBMkbLH9dp61pf7A=", + "owner": "xremap", + "repo": "nix-flake", + "rev": "e8bcb4e0724ff7782308399709a2744d0f6ff16d", + "type": "github" + }, + "original": { + "owner": "xremap", + "repo": "nix-flake", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nixos/flake.nix b/nixos/flake.nix new file mode 100644 index 0000000..47f7aff --- /dev/null +++ b/nixos/flake.nix @@ -0,0 +1,22 @@ +{ + description = "My nixos config"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + xremap-flake.url = "github:xremap/nix-flake"; + }; + + outputs = { self, nixpkgs, ... } @ inputs: + let + inherit (self) outputs; + system = "x86_64-linux"; + in + { + nixosConfigurations = { + nix = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ ./nixos/configuration.nix ]; + }; + }; + }; +} diff --git a/nixos/nixos/configuration.nix b/nixos/nixos/configuration.nix new file mode 100644 index 0000000..0593226 --- /dev/null +++ b/nixos/nixos/configuration.nix @@ -0,0 +1,146 @@ +{ inputs, lib, config, pkgs, ... }: + +{ + imports = + [ + "/etc/nixos/hardware-configuration.nix" + inputs.xremap-flake.nixosModules.default + ]; + + nix = { + settings = { + experimental-features = [ "nix-command" "flakes" ]; + }; + }; + + time.timeZone = "Europe/Stockholm"; + + i18n = { + defaultLocale = "sv_SE.UTF-8"; + + extraLocaleSettings = { + LC_ADDRESS = "sv_SE.UTF-8"; + LC_IDENTIFICATION = "sv_SE.UTF-8"; + LC_MEASUREMENT = "sv_SE.UTF-8"; + LC_MONETARY = "sv_SE.UTF-8"; + LC_NAME = "sv_SE.UTF-8"; + LC_NUMERIC = "sv_SE.UTF-8"; + LC_PAPER = "sv_SE.UTF-8"; + LC_TELEPHONE = "sv_SE.UTF-8"; + LC_TIME = "sv_SE.UTF-8"; + }; + }; + + users.users = { + thomas = { + isNormalUser = true; + description = "Thomas"; + extraGroups = [ "networkmanager" "wheel" "docker" ]; +# Also groups "uinput" and "input" for xremap to work with home-manager? + packages = with pkgs; [ ]; + shell = pkgs.fish; + }; + }; + # Enable automatic login for the user. + services.displayManager.autoLogin = { + enable = true; + user = "thomas"; + }; + systemd.services."getty@tty1".enable = false; + systemd.services."autovt@tty1".enable = false; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + services.xremap = { + userName = "thomas"; + withGnome = true; +# Macbook Pro keyboard: +# ctrl alt cmd space cmd alt +# 29 56 125 126 100 +# KEY_LEFTCTRL KEY_LEFTALT KEY_LEFTMETA KEY_RIGHTMETA KEY_RIGHTALT + yamlConfig = '' + modmap: + - name: Caps lock fix + remap: + CapsLock: + held: leftctrl + alone: Esc + alone_timeout_millis: 150 + - name: Space super + remap: + Space: + held: KEY_RO + alone: Space + virtual_modifiers: + - KEY_RO + keymap: + - remap: + KEY_RO-a: key_1 + KEY_RO-s: key_2 + KEY_RO-d: key_3 + KEY_RO-f: key_4 + KEY_RO-g: key_5 + ''; + }; + + # Remap right alt to left alt so both can be used for special characters + #services.xserver.displayManager.sessionCommands = "sleep 5 && ${pkgs.xorg.xmodmap}/bin/xmodmap -e 'keycode 100 = keycode 65' &"; + + services.xserver.xkb = { + layout = "se"; + variant = "mac"; + }; + console.keyMap = "sv-latin1"; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + virtualisation.docker.enable = true; + + programs = { + firefox.enable = true; + neovim = { + enable = true; + defaultEditor = true; + vimAlias = true; + }; + fish.enable = true; + git.enable = true; + tmux.enable = true; + }; + + environment.systemPackages = with pkgs; [ + vscode + neovim + xorg.xmodmap + docker-compose + kitty + ]; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + system.stateVersion = "24.11"; # Did you read the comment? + +} diff --git a/nixos/rebuild.sh b/nixos/rebuild.sh new file mode 100755 index 0000000..ac10681 --- /dev/null +++ b/nixos/rebuild.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +sudo nixos-rebuild switch --impure --flake ".#"