{"id":19325392,"url":"https://github.com/krypt0nn/dotfiles","last_synced_at":"2025-04-22T20:31:32.247Z","repository":{"id":240351706,"uuid":"802231999","full_name":"krypt0nn/dotfiles","owner":"krypt0nn","description":"My NixOS configuration files","archived":false,"fork":false,"pushed_at":"2025-04-19T17:48:07.000Z","size":295,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T20:25:09.834Z","etag":null,"topics":["nixos-config","nixos-configuration","nixos-dotfiles"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krypt0nn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-17T19:32:59.000Z","updated_at":"2025-04-19T17:48:10.000Z","dependencies_parsed_at":"2024-05-18T08:26:08.282Z","dependency_job_id":"a976bb8a-949a-4c3a-9fc2-7f772cb5caa0","html_url":"https://github.com/krypt0nn/dotfiles","commit_stats":null,"previous_names":["krypt0nn/dotfiles"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fdotfiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fdotfiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fdotfiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fdotfiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krypt0nn","download_url":"https://codeload.github.com/krypt0nn/dotfiles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250318719,"owners_count":21410983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nixos-config","nixos-configuration","nixos-dotfiles"],"created_at":"2024-11-10T02:09:56.240Z","updated_at":"2025-04-22T20:31:32.239Z","avatar_url":"https://github.com/krypt0nn.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NixOS system configuration\n\nMy own NixOS system configuration files.\n\nEdit `config.json` file to specify device and user.\n\n## Installation\n\nWe will be cooking impermanent BTRFS NixOS setup here. The core idea is to make\nfour subvolumes on the disk itself - `root` for `/`, and `nix`, `persistent`\nand `snapshots` for `/nix`, `/persistent` and `/snapshots` accordingly. Later on\nwe will be mounting those subvolumes to the folders inside of the `root` subvolume\nusing our nixos mounts config.\n\nValue of the `root` subvolume will be overwritten each reboot, while all the other\nsubvolumes, being outside of `root`, will keep their state. In particular, we're\nreally interested in `persistent`, which will keep our documents and other important\ndata saved on the disk between reboots, and `snapshots` which will be used to store\n`root` subvolume snapshots to keep track of previously written files. This is needed\nto being able to restore some sensitive data if it was forgotten to be persisted.\n\n### 1. Create base partitions\n\nLookup main storage drive name with the `lsblk`. Then:\n\n```bash\nsudo -i\n\nparted /dev/sda -- mklabel gpt\nparted /dev/sda -- mkpart ESP fat32 1MB 512MB\nparted /dev/sda -- set 1 esp on\nparted /dev/sda -- mkpart primary 512MB -16GB\nparted /dev/sda -- mkpart swap linux-swap -16GB 100%\n```\n\n### 2. Format the partitions\n\nVerify partitions names via said `lsblk` again. Then:\n\n```bash\nmkfs.fat -F 32 -n boot /dev/sda1\nmkfs.btrfs -L nixos /dev/sda2\nmkswap -L swap /dev/sda3\n```\n\n### 3. Mount created partitions\n\n```bash\nmount /dev/sda2 /mnt\nswapon /dev/sda3\n```\n\n### 4. Create btrfs subvolumes\n\n```bash\nbtrfs subvolume create /mnt/root\nbtrfs subvolume create /mnt/nix\nbtrfs subvolume create /mnt/persistent\nbtrfs subvolume create /mnt/snapshots\n```\n\n### 5. Create empty folders within the root subvolume for future mounts\n\nLater on we will be mounting other btrfs subvolumes to these folders, and root subvolume to the `/`.\n\n```bash\nmkdir /mnt/root/boot\nmkdir /mnt/root/nix\nmkdir /mnt/root/persistent\nmkdir /mnt/root/snapshots\n```\n\n### 6. Create blank snapshot of the root subvolume\n\nThis empty snapshot will be used to restore the clean system state for impermanence setup.\n\n```bash\nmkdir /mnt/snapshots/root\n\nbtrfs subvolume snapshot -r /mnt/root /mnt/snapshots/root/blank\n```\n\n### 7. Unmount the drive and mount subvolumes instead\n\n```bash\numount /mnt\n\nmount -o subvol=root /dev/sda2 /mnt\nmount -o subvol=nix /dev/sda2 /mnt/nix\nmount -o subvol=persistent /dev/sda2 /mnt/persistent\nmount -o subvol=snapshots /dev/sda2 /mnt/snapshots\n\nmount /dev/sda1 /mnt/boot\n```\n\n### 8. Generate basic nixos config\n\n```bash\nnixos-generate-config --root /mnt\n```\n\nVerify `/mnt/etc/nix/hardware-configuration.nix` file using `nano`. It must contain mount options\nfor `/nix`, `/persistent`, `/snapshots` and `/` being a btrfs subvolumes (options field), `/boot` being\na mount of `/dev/sda1`, and a swap device `/dev/sda3`.\n\nThen go to `/mnt/etc/nix/configuration.nix` and:\n\n1. Set `networking.hostName` to a proper value.\n2. Set `networking.networkmanager.enable = true;`.\n3. In `environment.systemPackages` enable `git`, `curl`, `wget`, `vim` and `micro` (more is better right?).\n4. Add flakes support with this: `nix.settings.experimental-features = [ \"nix-command\" \"flakes\" ];`.\n5. Allow unfree packages with this: `nixpkgs.config.allowUnfree = true;`.\n\n### 9. Proceed NixOS installation and setup root password afterwards\n\n```bash\nnixos-install\n\nreboot\n```\n\n### 10. Create password files\n\nCreate `root.password` and `\u003cyour username\u003e.password` files in the `/persistent` folder\ncontaining your accounts' encrypted passwords.\n\n```bash\nmkpasswd -m sha-512\n```\n\n### 11. Reproduce this configuration repo\n\nClone this repo and edit the `config.json` file to setup your user.\n\n```bash\nsudo git clone https://github.com/krypt0nn/dotfiles /system-flake\n\nsudo nixos-rebuild boot --flake /system-flake\n```\n\nDon't forget to update `hardware.nix` file (disks UUID-s) for your host device.\nNote that after the first restart system can clean all your changes due to\n`/persistent` folder initialization.\n\n### 12. Restart the system\n\n```bash\nreboot\n```\n\nDone. Welcome to your impermanent NixOS system!\n\n## Troubleshooting\n\n### 1. I lost my account! How do I login?\n\nBoot from the live iso used to install the system. Then:\n\n```bash\nsudo -i\n\nmount -o subvol=root /dev/sda2 /mnt\nmount -o subvol=nix /dev/sda2 /mnt/nix\nmount -o subvol=persistent /dev/sda2 /mnt/persistent\n\nnixos-enter\n```\n\nAlso you've probably forgot to create accounts' password files. Check out stage 10.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrypt0nn%2Fdotfiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrypt0nn%2Fdotfiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrypt0nn%2Fdotfiles/lists"}