From 83a7930cd457d3edfd19729729abd2aa21f6a5df Mon Sep 17 00:00:00 2001 From: "untilde.co" Date: Tue, 2 Jun 2026 16:47:16 +0200 Subject: [PATCH] added nix --- nix/flake.lock | 214 +++++++++++++++++++++++++++++++++++++++ nix/flake.nix | 61 +++++++++++ nix/hosts/cibo | 46 +++++++++ nix/justfile | 40 ++++++++ nix/modules/hardware | 7 ++ nix/modules/niri | 19 ++++ nix/modules/noctalia | 18 ++++ nix/modules/wayland | 51 ++++++++++ nix/packages/default.nix | 3 + nix/shells.nix | 9 ++ 10 files changed, 468 insertions(+) create mode 100644 nix/flake.lock create mode 100644 nix/flake.nix create mode 100644 nix/hosts/cibo create mode 100644 nix/justfile create mode 100644 nix/modules/hardware create mode 100644 nix/modules/niri create mode 100644 nix/modules/noctalia create mode 100644 nix/modules/wayland create mode 100644 nix/packages/default.nix create mode 100644 nix/shells.nix diff --git a/nix/flake.lock b/nix/flake.lock new file mode 100644 index 0000000..0417225 --- /dev/null +++ b/nix/flake.lock @@ -0,0 +1,214 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "niri": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1780056110, + "narHash": "sha256-t7lKVshV/srD0G06j4r5P5qj9zaDeZ9JYFCxHDGROZU=", + "owner": "niri-wm", + "repo": "niri", + "rev": "f9f43d826ab4014a7c302be28d7da33e12f5be37", + "type": "github" + }, + "original": { + "owner": "niri-wm", + "repo": "niri", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1757967192, + "narHash": "sha256-/aA9A/OBmnuOMgwfzdsXRusqzUpd8rQnQY8jtrHK+To=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0d7c15863b251a7a50265e57c1dca1a7add2e291", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1780243769, + "narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "331800de5053fcebacf6813adb5db9c9dca22a0c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1780243769, + "narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "331800de5053fcebacf6813adb5db9c9dca22a0c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "noctalia": { + "inputs": { + "nixpkgs": "nixpkgs_3", + "noctalia-qs": "noctalia-qs" + }, + "locked": { + "lastModified": 1780371321, + "narHash": "sha256-WCaU6npdMdjZSZHe3XATNDFijmzRnsV8V+iR80e5deg=", + "owner": "noctalia-dev", + "repo": "noctalia-shell", + "rev": "3aab45a2f34fd47666b05892b95054952e788de1", + "type": "github" + }, + "original": { + "owner": "noctalia-dev", + "repo": "noctalia-shell", + "type": "github" + } + }, + "noctalia-qs": { + "inputs": { + "nixpkgs": [ + "noctalia", + "nixpkgs" + ], + "systems": "systems_2", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1780194487, + "narHash": "sha256-M+YtjKCTkHrkplNaKVyaxfa8hAWjRF6wFOUBAZvxQ4U=", + "owner": "noctalia-dev", + "repo": "noctalia-qs", + "rev": "07398e12b54f194e3a2d47c87e3fd10b8eeaa27d", + "type": "github" + }, + "original": { + "owner": "noctalia-dev", + "repo": "noctalia-qs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "niri": "niri", + "nixpkgs": "nixpkgs_2", + "noctalia": "noctalia" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "niri", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1757989933, + "narHash": "sha256-9cpKYWWPCFhgwQTww8S94rTXgg8Q8ydFv9fXM6I8xQM=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "8249aa3442fb9b45e615a35f39eca2fe5510d7c3", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "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" + } + }, + "systems_2": { + "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": [ + "noctalia", + "noctalia-qs", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1775636079, + "narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix/flake.nix b/nix/flake.nix new file mode 100644 index 0000000..aa9f81f --- /dev/null +++ b/nix/flake.nix @@ -0,0 +1,61 @@ +{ + description = "NixOS flake with niri and noctalia"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + niri.url = "github:niri-wm/niri"; + noctalia.url = "github:noctalia-dev/noctalia-shell"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, niri, noctalia, flake-utils }: + let + # Use a single system for the NixOS configuration for now, or just let nixosSystem handle it. + # But since we have flake-utils, let's keep packages/devShells per-system. + perSystem = flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ + niri.overlays.default + noctalia.overlays.default + (self: super: { + noctalia = self.noctalia-shell or super.noctalia-shell; + }) + ]; + }; + in + { + packages = import ./packages { inherit pkgs; }; + devShells = import ./shells.nix { inherit pkgs; }; + } + ); + in + perSystem // { + nixosConfigurations = { + cibo = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + # We can pass overlays directly via nixpkgs.overlays if needed, + # or just rely on the modules to define it. + # Let's add the overlays to nixpkgs inside the module configuration. + ({ config, pkgs, ... }: { + nixpkgs.overlays = [ + niri.overlays.default + noctalia.overlays.default + (self: super: { + noctalia = self.noctalia-shell or super.noctalia-shell; + }) + ]; + }) + noctalia.nixosModules.default + ./hosts/cibo + ./modules/niri + ./modules/noctalia + ./modules/wayland + ./modules/hardware + ]; + }; + }; + }; +} diff --git a/nix/hosts/cibo b/nix/hosts/cibo new file mode 100644 index 0000000..805f012 --- /dev/null +++ b/nix/hosts/cibo @@ -0,0 +1,46 @@ +{ config, pkgs, modulesPath, ... }: + +{ + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + fileSystems."/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; + + # System identity + networking.hostName = "cibo"; + + # Users + users.users.untilde = { + isNormalUser = true; + description = "User"; + extraGroups = [ "wheel" "networkmanager" "input" "video" "audio" "seat" ]; + }; + users.groups.wheel.members = [ "untilde" ]; + security.sudo.wheelNeedsPassword = false; + + # Bootloader + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.supportedFilesystems = [ "ntfs" ]; + + # Locale + i18n.defaultLocale = "en_US.UTF-8"; + console.font = "Lat2-Terminus16"; + console.keyMap = "us"; + time.timeZone = "UTC"; + + # Services + services.openssh.enable = true; + services.gvfs.enable = true; + services.dbus.enable = true; + + # Nix + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.package = pkgs.nix; + + system.stateVersion = "23.11"; +} diff --git a/nix/justfile b/nix/justfile new file mode 100644 index 0000000..e7df2a9 --- /dev/null +++ b/nix/justfile @@ -0,0 +1,40 @@ +# Build and switch +build: + sudo nixos-rebuild switch --flake .#cibo + +# Build in check mode (dry run) +check: + sudo nixos-rebuild switch --flake .#cibo --dry-run + +# Evaluate configuration (quick syntax check) +eval: + nix eval .#nixosConfigurations.cibo.config.system.build.toplevel.drvPath + +# Update flake inputs +update: + nix flake update + +# Enter development shell +env: + nix develop + +# Rebuild and reboot +reboot: + sudo nixos-rebuild switch --flake .#cibo && sudo reboot + +# Garbage collect old generations +gc: + sudo nix-collect-garbage -d + nix-collect-garbage -d + +# Show system generations +generations: + nix-env --list-generations -p /nix/var/nix/profiles/system + +# Rollback to previous generation +rollback: + sudo nixos-rebuild switch --rollback + +# Build configuration in a VM +test: + nixos-rebuild build-vm --flake .#cibo diff --git a/nix/modules/hardware b/nix/modules/hardware new file mode 100644 index 0000000..9aef853 --- /dev/null +++ b/nix/modules/hardware @@ -0,0 +1,7 @@ +{ config, pkgs, modulesPath, ... }: + +{ + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; +} diff --git a/nix/modules/niri b/nix/modules/niri new file mode 100644 index 0000000..cbc84b9 --- /dev/null +++ b/nix/modules/niri @@ -0,0 +1,19 @@ +{ config, pkgs, ... }: + +{ + services.xserver.enable = false; + + services.greetd = { + enable = true; + settings = { + default_session = { + command = "${pkgs.tuigreet}/bin/tuigreet --time --cmd niri-session"; + user = "greeter"; + }; + initial_session = { + command = "niri-session"; + user = "untilde"; + }; + }; + }; +} diff --git a/nix/modules/noctalia b/nix/modules/noctalia new file mode 100644 index 0000000..5efe74d --- /dev/null +++ b/nix/modules/noctalia @@ -0,0 +1,18 @@ +{ config, pkgs, ... }: + +{ + environment.systemPackages = [ pkgs.noctalia ]; + + environment.etc."noctalia/config.json".text = '' + { + "modules": [ "tray", "clock", "battery", "workspace-switcher" ], + "bar": { + "position": "top", + "height": 40 + }, + "clock": { + "format": "%Y-%m-%d %H:%M:%S" + } + } + ''; +} diff --git a/nix/modules/wayland b/nix/modules/wayland new file mode 100644 index 0000000..7fba987 --- /dev/null +++ b/nix/modules/wayland @@ -0,0 +1,51 @@ +{ config, pkgs, ... }: + +{ + xdg.portal = { + enable = true; + wlr.enable = true; + extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + config.common.default = "*"; + }; + + security.polkit.enable = true; + + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + hardware.graphics.enable = true; + hardware.graphics.extraPackages = with pkgs; [ intel-vaapi-driver ]; + + fonts.packages = with pkgs; [ + nerd-fonts.fira-code + nerd-fonts.droid-sans-mono + liberation_ttf + noto-fonts + noto-fonts-cjk-sans + noto-fonts-color-emoji + ]; + + environment.systemPackages = with pkgs; [ + wl-clipboard + grim + slurp + alacritty + foot + firefox + ]; + + environment.sessionVariables = { + WAYLAND_DISPLAY = "wayland-1"; + XDG_SESSION_TYPE = "wayland"; + QT_QPA_PLATFORM = "wayland"; + SDL_VIDEODRIVER = "wayland"; + CLUTTER_BACKEND = "wayland"; + MOZ_ENABLE_WAYLAND = "1"; + }; + + powerManagement.enable = true; +} diff --git a/nix/packages/default.nix b/nix/packages/default.nix new file mode 100644 index 0000000..4d7532a --- /dev/null +++ b/nix/packages/default.nix @@ -0,0 +1,3 @@ +{ pkgs }: { + inherit (pkgs) niri noctalia; +} diff --git a/nix/shells.nix b/nix/shells.nix new file mode 100644 index 0000000..7adbeb1 --- /dev/null +++ b/nix/shells.nix @@ -0,0 +1,9 @@ +{ pkgs }: { + default = pkgs.mkShell { + packages = with pkgs; [ + nixpkgs-fmt + nix-index + nixos-rebuild + ]; + }; +} -- knotmirror 0.0.1