From da2d0899cee57d83fc5e4dd532a6795ba41f0fb5 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Thu, 9 Mar 2023 18:49:28 +0000 Subject: [PATCH] Wrap system configuration in a Flake --- bin/apply-system.bash | 2 +- bin/update-system.bash | 4 ++- flake.lock | 77 ++++++++++++++++++++++++++++++++++++++++ flake.nix | 19 ++++++++++ system/configuration.nix | 6 +++- users/tsv/home.nix | 2 -- 6 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/bin/apply-system.bash b/bin/apply-system.bash index 57a8596..cbd70ed 100755 --- a/bin/apply-system.bash +++ b/bin/apply-system.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash pushd ~/.my_config -sudo nixos-rebuild switch -I nixos-config=./system/configuration.nix +sudo nixos-rebuild switch --flake .# popd diff --git a/bin/update-system.bash b/bin/update-system.bash index bc0c796..b16526e 100755 --- a/bin/update-system.bash +++ b/bin/update-system.bash @@ -1,6 +1,8 @@ #!/usr/bin/env bash -sudo nix-channel --update +pushd ~/.my_config +nix flake update --recreate-lock-file +popd pushd ~/.my_config/bin ./apply-system.bash popd diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..cda9896 --- /dev/null +++ b/flake.lock @@ -0,0 +1,77 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + }, + "locked": { + "lastModified": 1678271387, + "narHash": "sha256-H2dv/i1LRlunRtrESirELzfPWdlG/6ElDB1ksO529H4=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "36999b8d19eb6eebb41983ef017d7e0095316af2", + "type": "github" + }, + "original": { + "id": "home-manager", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678293141, + "narHash": "sha256-lLlQHaR0y+q6nd6kfpydPTGHhl1rS9nU9OQmztzKOYs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c90c4025bb6e0c4eaf438128a3b2640314b1c58d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1678293141, + "narHash": "sha256-lLlQHaR0y+q6nd6kfpydPTGHhl1rS9nU9OQmztzKOYs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c90c4025bb6e0c4eaf438128a3b2640314b1c58d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2" + } + }, + "utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "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..9f2befd --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + description = "~tsv's system config"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + + outputs = inputs@{ nixpkgs, home-manager, ... }: { + nixosConfigurations = { + ritchie = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + + modules = [ + ./system/configuration.nix + ]; + }; + }; + }; +} diff --git a/system/configuration.nix b/system/configuration.nix index 7dbb46f..a1d5d33 100644 --- a/system/configuration.nix +++ b/system/configuration.nix @@ -44,6 +44,11 @@ in nix.settings.trusted-users = [ "root" "tsv" ]; + nix = { + extraOptions = "experimental-features = nix-command flakes"; + package = pkgs.nixFlakes; + }; + services.xserver.enable = true; services.xserver.displayManager.sddm.enable = true; services.xserver.desktopManager.plasma5.enable = true; @@ -77,7 +82,6 @@ in services.openssh.enable = true; - system.copySystemConfiguration = true; system.stateVersion = "22.11"; # Don't change this } diff --git a/users/tsv/home.nix b/users/tsv/home.nix index 6c8ee16..aa7729d 100644 --- a/users/tsv/home.nix +++ b/users/tsv/home.nix @@ -18,7 +18,6 @@ # Let Home Manager install and manage itself. programs.home-manager.enable = true; - nixpkgs.config.allowUnfree = true; home.sessionVariables = { @@ -60,7 +59,6 @@ wine winetricks zoom-us - (import (fetchTarball https://github.com/cachix/devenv/archive/v0.6.tar.gz)).default ]; programs.tmux = {