From 23b9f0667c2a761222ed4508c32fd43429f6d4a6 Mon Sep 17 00:00:00 2001 From: Juni Kim Date: Sun, 17 Jul 2022 22:33:15 -0400 Subject: [PATCH] nix flakes --- configuration.nix | 34 --------------------- flake.lock | 78 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 18 +++++++++++ hardware.nix | 34 +++++++++++++++++++++ users.nix | 7 +---- 5 files changed, 131 insertions(+), 40 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hardware.nix diff --git a/configuration.nix b/configuration.nix index 0e6ae44..b89b8f0 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,23 +1,6 @@ { config, pkgs, ... }: { - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ./users.nix - ]; - - # Use the systemd-boot EFI boot loader. - boot.loader.grub = { - enable = true; - version = 2; - device = "/dev/vda"; - }; - networking.hostName = "nixbox"; # Define your hostname. - - # Set your time zone. time.timeZone = "US/Eastern"; - - # Select internationalisation properties. i18n.defaultLocale = "en_US.UTF-8"; console = { font = "Lat2-Terminus16"; @@ -42,10 +25,6 @@ ]; virtualisation.docker.enable = 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; @@ -78,18 +57,5 @@ # networking.firewall.allowedUDPPorts = [ ... ]; # Or disable the firewall altogether. networking.firewall.enable = false; - - # Copy the NixOS configuration file and link it from the resulting system - # (/run/current-system/configuration.nix). This is useful in case you - # accidentally delete configuration.nix. system.copySystemConfiguration = true; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "22.05"; # Did you read the comment? } - diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..af4ee4b --- /dev/null +++ b/flake.lock @@ -0,0 +1,78 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + }, + "locked": { + "lastModified": 1657887110, + "narHash": "sha256-8VV0/kZed2z8fGtEc2zr+WLxTow+JTIlMjnSisyv0GQ=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "4c5106ed0f3168ff2df21b646aef67e86cbfc11c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1654230545, + "narHash": "sha256-8Vlwf0x8ow6pPOK2a04bT+pxIeRnM1+O0Xv9/CuDzRs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "236cc2971ac72acd90f0ae3a797f9f83098b17ec", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1657815135, + "narHash": "sha256-+5Jby1ayRjtSgsM5IpRNeUgdcIutCKQWR6sypRtd1RE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c06d5fa9c605d143b15cafdbbb61c7c95388d76e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2" + } + }, + "utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e16a865 --- /dev/null +++ b/flake.nix @@ -0,0 +1,18 @@ +{ + description = "Multi-user NixOS example"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05"; + inputs.home-manager.url = "github:nix-community/home-manager"; + + outputs = { self, nixpkgs, home-manager, ... }: { + nixosConfigurations.nixbox = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + home-manager.nixosModule + ./hardware.nix + ./configuration.nix + ./users.nix + ]; + }; + }; +} diff --git a/hardware.nix b/hardware.nix new file mode 100644 index 0000000..02d7a60 --- /dev/null +++ b/hardware.nix @@ -0,0 +1,34 @@ +# 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") ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.grub = { + enable = true; + version = 2; + device = "/dev/vda"; + }; + networking.hostName = "nixbox"; # Define your hostname. + + boot.initrd.availableKernelModules = [ + "ahci" "xhci_pci" "virtio_pci" + "sr_mod" "virtio_blk" + ]; + + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; + networking.useDHCP = lib.mkDefault true; + + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/users.nix b/users.nix index 6f5254e..d0b6eb0 100644 --- a/users.nix +++ b/users.nix @@ -1,12 +1,8 @@ { pkgs, ... }: let - home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/master.tar.gz"; prefix = "/server/project"; in { - imports = [ - (import "${home-manager}/nixos") - ]; systemd.tmpfiles.rules = [ "d /server 0777 root root" @@ -17,7 +13,7 @@ in project = {}; }; - users.users = + users.users = let user = { zsh ? false, manager ? false, name, passwd }: { @@ -34,7 +30,6 @@ in junikim = user { manager = true; name = "junikim"; passwd = "1234"; }; a = user { zsh = true; name = "a"; passwd = "1234"; }; b = user { name = "b"; passwd = "1234"; }; - c = user { name = "c"; passwd = "1234"; }; };