From ecc0d8ffe82bf0d673644bd057816b52bf435923 Mon Sep 17 00:00:00 2001 From: andromeda Date: Fri, 9 Jan 2026 22:27:04 +0100 Subject: [PATCH] init --- configuration.nix | 43 ++++++++++++++ disko.nix | 57 ++++++++++++++++++ flake.lock | 118 +++++++++++++++++++++++++++++++++++++ flake.nix | 23 ++++++++ hardware-configuration.nix | 24 ++++++++ impermanence.nix | 16 +++++ run.sh | 1 + 7 files changed, 282 insertions(+) create mode 100644 configuration.nix create mode 100644 disko.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hardware-configuration.nix create mode 100644 impermanence.nix create mode 100755 run.sh diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..aa7f343 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,43 @@ +{ + modulesPath, + pkgs, + ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + (modulesPath + "/profiles/qemu-guest.nix") + ./disko.nix + ./impermanence.nix + ]; + + # boot + boot.loader.grub = { + efiSupport = true; + efiInstallAsRemovable = true; + }; + + # cloud-init + networking.useDHCP = false; + services.cloud-init = { + enable = true; + network.enable = true; + }; + + # ssh + services.openssh.enable = true; + + # root + users.mutableUsers = false; + users.users.root = { + packages = [ + pkgs.dust + pkgs.git + pkgs.neovim + pkgs.tree + ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJy2VD362wUcu0lKj2d6OIU8dbAna0Lu/NaAYIj8gdIA andromeda@lenovo" + ]; + }; + system.stateVersion = "26.05"; +} diff --git a/disko.nix b/disko.nix new file mode 100644 index 0000000..42ac3cb --- /dev/null +++ b/disko.nix @@ -0,0 +1,57 @@ +{ + disko.devices = { + disk = { + disk1 = { + device = "/dev/sda"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + boot = { + name = "boot"; + size = "1M"; + type = "EF02"; + }; + esp = { + name = "ESP"; + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + size = "100%"; + content = { + extraArgs = ["-f"]; + type = "btrfs"; + subvolumes = { + "/root" = { + #mountpoint = "/"; + }; + "/nix" = { + mountpoint = "/nix"; + }; + "/persist" = { + mountpoint = "/persist"; + }; + }; + }; + }; + }; + }; + }; + }; + nodev = { + "/" = { + fsType = "tmpfs"; + mountOptions = [ + "defaults" + "mode=755" + ]; + }; + }; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b018c59 --- /dev/null +++ b/flake.lock @@ -0,0 +1,118 @@ +{ + "nodes": { + "disko": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1766150702, + "narHash": "sha256-P0kM+5o+DKnB6raXgFEk3azw8Wqg5FL6wyl9jD+G5a4=", + "owner": "nix-community", + "repo": "disko", + "rev": "916506443ecd0d0b4a0f4cf9d40a3c22ce39b378", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "impermanence", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747978958, + "narHash": "sha256-pQQnbxWpY3IiZqgelXHIe/OAE/Yv4NSQq7fch7M6nXQ=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "7419250703fd5eb50e99bdfb07a86671939103ea", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "impermanence": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1767822991, + "narHash": "sha256-iyrn9AcPZCoyxX4OT8eMkBsjG7SRUQXXS/V1JzxS7rA=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "82e5bc4508cab9e8d5a136626276eb5bbce5e9c5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1763618868, + "narHash": "sha256-v5afmLjn/uyD9EQuPBn7nZuaZVV9r+JerayK/4wvdWA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a8d610af3f1a5fb71e23e08434d8d61a466fc942", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1748026106, + "narHash": "sha256-6m1Y3/4pVw1RWTsrkAK2VMYSzG4MMIj7sqUy7o8th1o=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "063f43f2dbdef86376cc29ad646c45c46e93234c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1767887170, + "narHash": "sha256-1AndIor9+GQuTAfcdA4TZanYwcxyikA+xQNLd6rv7Uw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "fe0ecf20d1c7f079dcba0b6db8cacd8fdc0d32f6", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "disko": "disko", + "impermanence": "impermanence", + "nixpkgs": "nixpkgs_3" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..da5afe4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + disko.url = "github:nix-community/disko"; + impermanence.url = "github:nix-community/impermanence"; + }; + outputs = { + disko, + nixpkgs, + impermanence, + ... + }: { + nixosConfigurations.default = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + disko.nixosModules.disko + impermanence.nixosModules.impermanence + ./configuration.nix + ./hardware-configuration.nix + ]; + }; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..bb23f0b --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,24 @@ +# 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 + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + # 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.ens18.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/impermanence.nix b/impermanence.nix new file mode 100644 index 0000000..1955354 --- /dev/null +++ b/impermanence.nix @@ -0,0 +1,16 @@ +{ + fileSystems."/nix".neededForBoot = true; + fileSystems."/persist".neededForBoot = true; + environment.persistence."/persist" = { + enable = true; + hideMounts = true; + directories = [ + "/var/log" + "/var/lib/nixos" + "/var/lib/systemd/coredump" + ]; + files = [ + "/etc/machine-id" + ]; + }; +} diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..0b74e2b --- /dev/null +++ b/run.sh @@ -0,0 +1 @@ +nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./hardware-configuration.nix --flake .#default --target-host root@109.199.104.83