~> ssh nixos@192.168.11.7
The authenticity of host '192.168.11.7 (192.168.11.7)' can't be established.
ED25519 key fingerprint is SHA256:VaSGKAAf3wkC1x9oRLPUurQZtNbhCJswR+emvlXcWMw.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.11.7' (ED25519) to the list of known hosts.
(nixos@192.168.11.7) Password:
[nixos@nixos:~]$ sudo -i
[root@nixos:~]#
[root@nixos:~]# parted /dev/sda -- print list
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
3 1049kB 512MB 511MB ESP boot, esp
1 512MB 99.4GB 98.9GB root
2 99.4GB 107GB 7999MB swap swap
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Model: NECVMWar VMware IDE CDR00 (scsi)
Disk /dev/sr0: 1003MB
Sector size (logical/physical): 2048B/2048B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
2 36.2MB 48.8MB 12.6MB primary esp
パーティションの番号に対応した sda1、sda2、sda3 が出来上がっている。
1
2
[root@nixos:~]# ls /dev/sda*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda3
[root@nixos:~]# nixos-generate-config --root /mnt
writing /mnt/etc/nixos/hardware-configuration.nix...
writing /mnt/etc/nixos/configuration.nix...
For more hardware-specific settings, see https://github.com/NixOS/nixos-hardware.
{config,lib,pkgs,...}:{imports=[# Include the results of the hardware scan../hardware-configuration.nix];# Use the systemd-boot EFI boot loader.boot.loader.systemd-boot.enable=true;boot.loader.efi.canTouchEfiVariables=true;networking.hostName="nixos";# Define your hostname.time.timeZone="Asia/Tokyo";i18n.defaultLocale="en_US.UTF-8";users.users.bombrary={isNormalUser=true;extraGroups=["wheel"];# Enable ‘sudo’ for the user.};# List packages installed in system profile. To search, run:# $ nix search wgetenvironment.systemPackages=withpkgs;[vimgit];# Some programs need SUID wrappers, can be configured further or are# started in user sessions.programs.mtr.enable=true;services.openssh.enable=true;nix.settings.experimental-features=["nix-command""flakes"];# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,# and migrated your data accordingly.## For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .system.stateVersion="23.11";# Did you read the comment?}
[bombrary@nixos:~]$ man nixos-rebuild
...
--flake flake-uri[#name]
Build the NixOS system from the specified flake. It defaults to the directory containing the
target of the symlink /etc/nixos/flake.nix, if it exists. The flake must contain an output named
‘nixosConfigurations.name’. If name is omitted, it default to the current host name.
そして、nixosConfigurations.<name>に指定するのはlib.nixosSystemという関数である。これに関してはredditで同じ疑問を抱いている人がいるが、公式docには(少なくともnixpkgsとnixのdocs/下をnixosSystemで全文検索した限りだと)example的な記載しかない。どんな引数を指定すればよいのか、というのは公式docでは見つからないため、現在Wikiや上記参考記事を見ながら設定するほかない(これは、まだflakeがexperimentalな概念だからだろうか…? そもそもいつまでexperimentalなんだよ、というのには事情があるらしく、Why are flakes still experimental?の話が参考になる)。
{description="NixOS and Home Manager Configuration";inputs={nixos.url=github:NixOS/nixpkgs/nixos-23.11;};outputs={self,nixos}:{nixosConfigurations={minimal=nixos.lib.nixosSystem{system="x86_64-linux";modules=[./hosts/minimal/configuration.nix];};};};}
[bombrary@nixos:~/dotfiles]$ nix registry list
global flake:agda github:agda/agda
global flake:arion github:hercules-ci/arion
global flake:blender-bin github:edolstra/nix-warez?dir=blender
global flake:bundlers github:NixOS/bundlers
global flake:cachix github:cachix/cachix
global flake:composable github:ComposableFi/composable
global flake:disko github:nix-community/disko
global flake:dreampkgs github:nix-community/dreampkgs
global flake:dwarffs github:edolstra/dwarffs
global flake:emacs-overlay github:nix-community/emacs-overlay
global flake:fenix github:nix-community/fenix
global flake:flake-parts github:hercules-ci/flake-parts
global flake:flake-utils github:numtide/flake-utils
global flake:gemini github:nix-community/flake-gemini
global flake:helix github:helix-editor/helix
global flake:hercules-ci-agent github:hercules-ci/hercules-ci-agent
global flake:hercules-ci-effects github:hercules-ci/hercules-ci-effects
global flake:home-manager github:nix-community/home-manager
global flake:hydra github:NixOS/hydra
global flake:mach-nix github:DavHau/mach-nix
global flake:nickel github:tweag/nickel
global flake:nimble github:nix-community/flake-nimble
global flake:nix github:NixOS/nix
global flake:nix-darwin github:LnL7/nix-darwin
global flake:nix-serve github:edolstra/nix-serve
global flake:nixops github:NixOS/nixops
global flake:nixos-hardware github:NixOS/nixos-hardware
global flake:nixos-homepage github:NixOS/nixos-homepage
global flake:nixos-search github:NixOS/nixos-search
global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable
global flake:nur github:nix-community/NUR
global flake:patchelf github:NixOS/patchelf
global flake:poetry2nix github:nix-community/poetry2nix
global flake:pridefetch github:SpyHoodle/pridefetch
global flake:sops-nix github:Mic92/sops-nix
global flake:systems github:nix-systems/default
global flake:templates github:NixOS/templates
{config,lib,pkgs,...}:{time.timeZone="Asia/Tokyo";i18n.defaultLocale="en_US.UTF-8";users.users.bombrary={isNormalUser=true;extraGroups=["wheel"];# Enable ‘sudo’ for the user.};# List packages installed in system profile. To search, run:# $ nix search wgetenvironment.systemPackages=withpkgs;[vimgit];}
{config,lib,pkgs,...}:{imports=[# Include the results of the hardware scan../hardware-configuration.nix../../modules/common.nix];networking.hostName="nixos";# Define your hostname.# Use the systemd-boot EFI boot loader.boot.loader.systemd-boot.enable=true;boot.loader.efi.canTouchEfiVariables=true;# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,# and migrated your data accordingly.## For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .system.stateVersion="23.11";# Did you read the comment?}
--flake flake-uri[#name]
Build Home Manager configuration from the flake, which must contain the output homeConfigurations.name. If no name is specified it will first try username@hostname and then username.
init [--switch [dir]]
Generates an initial home.nix file for the current user. If Nix flakes are enabled, then this
command also generates a flake.nix file.
{description="NixOS and Home Manager Configuration";inputs={nixos.url=github:NixOS/nixpkgs/nixos-23.11;nixpkgs.url=github:NixOS/nixpkgs/nixos-unstable;home-manager={url=github:nix-community/home-manager;inputs.nixpkgs.follows="nixpkgs";};};outputs={self,nixos,nixpkgs,home-manager}:{nixosConfigurations={minimal=nixos.lib.nixosSystem{system="x86_64-linux";modules=[./hosts/minimal/configuration.nix];};};homeConfigurations={bombrary=home-manager.lib.homeManagerConfiguration{pkgs=importnixpkgs{system="x86_64-linux";};modules=[./home/bombrary/home.nix];};};};}
[root@nixos:~]# nixos-generate-config --root /mnt
writing /mnt/etc/nixos/hardware-configuration.nix...
writing /mnt/etc/nixos/configuration.nix...
For more hardware-specific settings, see https://github.com/NixOS/nixos-hardware.