From fcf66bf6721c9d1b5e62672980f296675b1f082a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20H=C3=A9mono?= Date: Wed, 7 Aug 2024 18:35:29 +0200 Subject: [PATCH 1/5] feat: switch gwiad to NixOS ! --- flake.lock | 72 ++++++++++++ flake.nix | 12 ++ hosts/gwiad/configuration.nix | 151 +++++++++++++++++++++++++ hosts/gwiad/hardware-configuration.nix | 54 +++++++++ 4 files changed, 289 insertions(+) create mode 100644 hosts/gwiad/configuration.nix create mode 100644 hosts/gwiad/hardware-configuration.nix diff --git a/flake.lock b/flake.lock index d1a3f6b..1162b13 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,39 @@ { "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-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "mysecrets": { "flake": false, "locked": { @@ -18,6 +52,28 @@ "url": "ssh://forgejo@git.hemono.fr/jhemono/nix-secrets.git" } }, + "nix-vscode-extensions": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722994187, + "narHash": "sha256-K5V2N5HkGaLpf5StNbtKBM6O9K+CYF/8F8hlGUVgiKk=", + "owner": "nix-community", + "repo": "nix-vscode-extensions", + "rev": "6fc50b0716bc415cfd1bc81bb9e198d78cd03b3d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-vscode-extensions", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1718208800, @@ -37,6 +93,7 @@ "root": { "inputs": { "mysecrets": "mysecrets", + "nix-vscode-extensions": "nix-vscode-extensions", "nixpkgs": "nixpkgs", "sops-nix": "sops-nix" } @@ -63,6 +120,21 @@ "repo": "sops-nix", "type": "github" } + }, + "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", diff --git a/flake.nix b/flake.nix index e5ed6ef..a044690 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,11 @@ url = "git+ssh://forgejo@git.hemono.fr/jhemono/nix-secrets.git?ref=main&shallow=1"; flake = false; }; + + nix-vscode-extensions = { + url = "github:nix-community/nix-vscode-extensions"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { self, nixpkgs, ... }@inputs: { @@ -31,6 +36,13 @@ # inputs.home-manager.nixosModules.default ]; }; + gwiad = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs;}; + modules = [ + ./hosts/gwiad/configuration.nix + # inputs.home-manager.nixosModules.default + ]; + }; }; }; } diff --git a/hosts/gwiad/configuration.nix b/hosts/gwiad/configuration.nix new file mode 100644 index 0000000..2d3fec9 --- /dev/null +++ b/hosts/gwiad/configuration.nix @@ -0,0 +1,151 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, inputs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Boot configuration + boot.loader.systemd-boot.enable = true; + boot.loader.systemd-boot.configurationLimit = 10; + boot.loader.efi.canTouchEfiVariables = true; + + # Networking + networking.hostName = "gwiad"; + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Paris"; + + # Console + console = { + keyMap = "fr"; + }; + + # Sway + programs.sway = { + enable = true; + }; + programs.waybar = { + enable = true; + }; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # For VSCode + nixpkgs = { + config.allowUnfree = true; + overlays = [ + inputs.nix-vscode-extensions.overlays.default + ]; + }; + + # User account + users.users.jhemono = { + isNormalUser = true; + uid = 1000; + extraGroups = [ "wheel" ]; # Enable 'sudo' for the user. + packages = with pkgs; let + tex = texlive.combine { + inherit (texlive) + scheme-basic + moderncv + fontawesome5 + pgf # For tikz.sty + multirow + arydshln; + }; + my-vscode = vscode-with-extensions.override { + vscodeExtensions = with vscode-marketplace; [ + ms-python.python + ms-python.vscode-pylance + ms-python.debugpy + ]; + }; + in [ + bemenu # slurpshot + grim # slurpshot + slurp # slurpshot + imv # slurpshot + alacritty + chromium + hunspell + hunspellDicts.fr-classique + inkscape + kanshi + libreoffice-fresh + my-vscode + nixfmt + pass-wayland + pulsemixer + pwgen + tex + zathura + ]; + }; + users.groups.jhemono.gid = 1000; + + # System packages + environment.systemPackages = with pkgs; [ + android-file-transfer + android-tools + bc + git + htop + jq + ncdu + rclone + tmux + tree + unzip + vim + ]; + + programs.firefox = { + enable = true; + nativeMessagingHosts.packages = with pkgs; [ passff-host ]; + }; + programs.browserpass.enable = true; + + # Fonts + fonts.packages = with pkgs; [ + monocraft + ]; + + # GNOME + services.xserver = { + enable = true; + xkb.layout = "fr"; + displayManager.gdm.enable = true; + desktopManager.gnome.enable = true; + }; + + environment.variables.EDITOR = "vim"; + + # Nix configuration + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + nix.settings.auto-optimise-store = true; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + + + system.stateVersion = "24.05"; + +} diff --git a/hosts/gwiad/hardware-configuration.nix b/hosts/gwiad/hardware-configuration.nix new file mode 100644 index 0000000..e8dadd8 --- /dev/null +++ b/hosts/gwiad/hardware-configuration.nix @@ -0,0 +1,54 @@ +# 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 = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/c0db6860-b647-42eb-943f-892dde3847b2"; + fsType = "btrfs"; + options = [ "subvol=@" ]; + }; + + boot.initrd.luks.devices."root".device = "/dev/disk/by-uuid/698c62d9-1115-4756-b812-1daae4898b83"; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/c0db6860-b647-42eb-943f-892dde3847b2"; + fsType = "btrfs"; + options = [ "subvol=@home" ]; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/16A2-B1E1"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + fileSystems."/var" = + { device = "/dev/disk/by-uuid/c0db6860-b647-42eb-943f-892dde3847b2"; + fsType = "btrfs"; + options = [ "subvol=@var" ]; + }; + + 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.enp1s0f0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} From c4be4abdebda6cc6611e1b8d6f04d08a2f56871f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20H=C3=A9mono?= Date: Wed, 7 Aug 2024 19:01:00 +0200 Subject: [PATCH 2/5] feat: add unstable nixpkgs overlay --- flake.lock | 17 +++++++++++++++++ flake.nix | 11 +++++++++-- hosts/gwiad/configuration.nix | 3 ++- overlays/default.nix | 11 +++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 overlays/default.nix diff --git a/flake.lock b/flake.lock index 1162b13..a83a5c1 100644 --- a/flake.lock +++ b/flake.lock @@ -90,11 +90,28 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1722813957, + "narHash": "sha256-IAoYyYnED7P8zrBFMnmp7ydaJfwTnwcnqxUElC1I26Y=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cb9a96f23c491c081b38eab96d22fa958043c9fa", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "mysecrets": "mysecrets", "nix-vscode-extensions": "nix-vscode-extensions", "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable", "sops-nix": "sops-nix" } }, diff --git a/flake.nix b/flake.nix index a044690..1e6bfa6 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,7 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; # Secrets management sops-nix = { @@ -27,7 +28,13 @@ }; }; - outputs = { self, nixpkgs, ... }@inputs: { + outputs = { self, nixpkgs, ... }@inputs: let + inherit (self) outputs; + in { + + # Custom packages and modifications, exported as overlays + overlays = import ./overlays {inherit inputs;}; + nixosConfigurations = { sesame = nixpkgs.lib.nixosSystem { specialArgs = {inherit inputs;}; @@ -37,7 +44,7 @@ ]; }; gwiad = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;}; + specialArgs = {inherit inputs outputs;}; modules = [ ./hosts/gwiad/configuration.nix # inputs.home-manager.nixosModules.default diff --git a/hosts/gwiad/configuration.nix b/hosts/gwiad/configuration.nix index 2d3fec9..509200d 100644 --- a/hosts/gwiad/configuration.nix +++ b/hosts/gwiad/configuration.nix @@ -2,7 +2,7 @@ # your system. Help is available in the configuration.nix(5) man page, on # https://search.nixos.org/options and in the NixOS manual (`nixos-help`). -{ config, lib, pkgs, inputs, ... }: +{ config, lib, pkgs, inputs, outputs, ... }: { imports = @@ -43,6 +43,7 @@ config.allowUnfree = true; overlays = [ inputs.nix-vscode-extensions.overlays.default + outputs.overlays.unstable-packages ]; }; diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..1d0fb57 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,11 @@ +# This file defines overlays +{inputs, ...}: { + # When applied, the unstable nixpkgs set (declared in the flake inputs) will + # be accessible through 'pkgs.unstable' + unstable-packages = final: _prev: { + unstable = import inputs.nixpkgs-unstable { + system = final.system; + config.allowUnfree = true; + }; + }; +} From ac8c7b3deda663cc736b47e6ab6bc4e16a774385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20H=C3=A9mono?= Date: Wed, 7 Aug 2024 19:01:20 +0200 Subject: [PATCH 3/5] feat: switch to VSCode from unstable --- hosts/gwiad/configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/gwiad/configuration.nix b/hosts/gwiad/configuration.nix index 509200d..071cb09 100644 --- a/hosts/gwiad/configuration.nix +++ b/hosts/gwiad/configuration.nix @@ -62,7 +62,7 @@ multirow arydshln; }; - my-vscode = vscode-with-extensions.override { + my-vscode = unstable.vscode-with-extensions.override { vscodeExtensions = with vscode-marketplace; [ ms-python.python ms-python.vscode-pylance From b4aaa2f57ac28d6bd1208cb159c2624034b46801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20H=C3=A9mono?= Date: Tue, 20 Aug 2024 19:07:48 +0200 Subject: [PATCH 4/5] Added development packages --- hosts/gwiad/configuration.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hosts/gwiad/configuration.nix b/hosts/gwiad/configuration.nix index 071cb09..587a022 100644 --- a/hosts/gwiad/configuration.nix +++ b/hosts/gwiad/configuration.nix @@ -67,6 +67,8 @@ ms-python.python ms-python.vscode-pylance ms-python.debugpy + ms-python.black-formatter + ms-python.isort ]; }; in [ @@ -88,6 +90,11 @@ pwgen tex zathura + + # General development + poetry + pre-commit + nodejs ]; }; users.groups.jhemono.gid = 1000; From 85610c311266fedcf426a0cd008dcda5a3e70b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20H=C3=A9mono?= Date: Tue, 20 Aug 2024 19:07:54 +0200 Subject: [PATCH 5/5] update --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index a83a5c1..75be683 100644 --- a/flake.lock +++ b/flake.lock @@ -61,11 +61,11 @@ ] }, "locked": { - "lastModified": 1722994187, - "narHash": "sha256-K5V2N5HkGaLpf5StNbtKBM6O9K+CYF/8F8hlGUVgiKk=", + "lastModified": 1724117347, + "narHash": "sha256-/nfm6P0owPtCRjT8ktq/8OChtg2HpkrvNaDJGm9N1Lk=", "owner": "nix-community", "repo": "nix-vscode-extensions", - "rev": "6fc50b0716bc415cfd1bc81bb9e198d78cd03b3d", + "rev": "2ef60116ef361d988317cbe52a09acfeda7d3416", "type": "github" }, "original": { @@ -76,11 +76,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1718208800, - "narHash": "sha256-US1tAChvPxT52RV8GksWZS415tTS7PV42KTc2PNDBmc=", + "lastModified": 1723938990, + "narHash": "sha256-9tUadhnZQbWIiYVXH8ncfGXGvkNq3Hag4RCBEMUk7MI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cc54fb41d13736e92229c21627ea4f22199fee6b", + "rev": "c42fcfbdfeae23e68fc520f9182dde9f38ad1890", "type": "github" }, "original": { @@ -92,11 +92,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1722813957, - "narHash": "sha256-IAoYyYnED7P8zrBFMnmp7ydaJfwTnwcnqxUElC1I26Y=", + "lastModified": 1723991338, + "narHash": "sha256-Grh5PF0+gootJfOJFenTTxDTYPidA3V28dqJ/WV7iis=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cb9a96f23c491c081b38eab96d22fa958043c9fa", + "rev": "8a3354191c0d7144db9756a74755672387b702ba", "type": "github" }, "original": { @@ -125,11 +125,11 @@ ] }, "locked": { - "lastModified": 1718137936, - "narHash": "sha256-psA+1Q5fPaK6yI3vzlLINNtb6EeXj111zQWnZYyJS9c=", + "lastModified": 1723501126, + "narHash": "sha256-N9IcHgj/p1+2Pvk8P4Zc1bfrMwld5PcosVA0nL6IGdE=", "owner": "Mic92", "repo": "sops-nix", - "rev": "c279dec105dd53df13a5e57525da97905cc0f0d6", + "rev": "be0eec2d27563590194a9206f551a6f73d52fa34", "type": "github" }, "original": {