From 5efe0fd5a5e736abd7ba8a03d5a607b776aad26b Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 6 Mar 2023 21:00:44 +0100 Subject: [PATCH] Switch to flakes --- .gitignore | 1 + nixos/apply-system.sh | 2 +- nixos/apply-users.sh | 3 +- nixos/flake.lock | 64 ++++++++++++++++++++++++++++++++++ nixos/flake.nix | 45 ++++++++++++++++++++++++ nixos/system/configuration.nix | 6 ++++ nixos/update-system.sh | 2 -- nixos/update-users.sh | 2 -- nixos/update.sh | 2 ++ 9 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 nixos/flake.lock create mode 100644 nixos/flake.nix delete mode 100755 nixos/update-system.sh delete mode 100755 nixos/update-users.sh create mode 100755 nixos/update.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/nixos/apply-system.sh b/nixos/apply-system.sh index 240309f..6a83754 100755 --- a/nixos/apply-system.sh +++ b/nixos/apply-system.sh @@ -1,4 +1,4 @@ #!/bin/sh pushd ~/projects/sisyphus/nixos -sudo nixos-rebuild switch -I nixos-config=./system/configuration.nix +sudo nixos-rebuild switch --flake .# popd diff --git a/nixos/apply-users.sh b/nixos/apply-users.sh index 67d872a..f1b3264 100755 --- a/nixos/apply-users.sh +++ b/nixos/apply-users.sh @@ -1,4 +1,5 @@ #!/bin/sh pushd ~/projects/sisyphus/nixos -home-manager switch -f ./users/tdpeuter/home.nix +nix build .#homeManagerConfigurations.tdpeuter.activationPackage +./result/activate popd diff --git a/nixos/flake.lock b/nixos/flake.lock new file mode 100644 index 0000000..72ee0d7 --- /dev/null +++ b/nixos/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1677757546, + "narHash": "sha256-tA1ukoluctzLVyWRaKtD4KlTwgXbUsGB5vcyni1OJ9I=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "86bb69b0b1e10d99a30c4352f230f03106dd0f8a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-22.11", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678072060, + "narHash": "sha256-6a9Tbjhir5HxDx4uw0u6Z+LHUfYf7tsT9QxF9FN/32w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "47c003416297e4d59a5e3e7a8b15cdbdf5110560", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-22.11", + "type": "indirect" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + }, + "utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nixos/flake.nix b/nixos/flake.nix new file mode 100644 index 0000000..a749af1 --- /dev/null +++ b/nixos/flake.nix @@ -0,0 +1,45 @@ +{ + description = "System configuration"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-22.11"; + home-manager.url = "github:nix-community/home-manager/release-22.11"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; # Use flake tools? + + pkgs = import nixpkgs { + inherit system; + config = { allowUnfree = true; }; + }; + + lib = nixpkgs.lib; + in { + homeManagerConfigurations = { + tdpeuter = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + modules = [ + ./users/tdpeuter/home.nix + { + home = { + username = "tdpeuter"; + homeDirectory = "/home/tdpeuter"; + }; + } + ]; + }; + }; + + nixosConfigurations = { + Tibo-NixTest = lib.nixosSystem { # Use hostname + inherit system; + modules = [ + ./system/configuration.nix + ]; + }; + }; + }; +} diff --git a/nixos/system/configuration.nix b/nixos/system/configuration.nix index 15a0361..da793f2 100644 --- a/nixos/system/configuration.nix +++ b/nixos/system/configuration.nix @@ -10,6 +10,12 @@ ./hardware-configuration.nix ]; + # Nix Flakes + nix.package = pkgs.nixFlakes; + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + # Use the systemd-boot EFI boot loader.] boot.loader = { systemd-boot.enable = true; diff --git a/nixos/update-system.sh b/nixos/update-system.sh deleted file mode 100755 index 0a7262f..0000000 --- a/nixos/update-system.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -sudo nix-channel --update diff --git a/nixos/update-users.sh b/nixos/update-users.sh deleted file mode 100755 index aadccd6..0000000 --- a/nixos/update-users.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -nix-channel --update diff --git a/nixos/update.sh b/nixos/update.sh new file mode 100755 index 0000000..919cd48 --- /dev/null +++ b/nixos/update.sh @@ -0,0 +1,2 @@ +#!/bin/sh +nix flake update