From e210bca113305f5631b1cbfe5308778e71dbbf5c Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Wed, 18 Dec 2024 01:05:41 +0000 Subject: [PATCH] converted to flake --- configuration.nix | 30 +------------- flake.lock | 103 ++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 42 +++++++++++++++++++ git.nix | 3 +- users.nix | 23 ++++++++--- 5 files changed, 166 insertions(+), 35 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/configuration.nix b/configuration.nix index 16e4b4f..d9d0d4d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,22 +1,10 @@ -{ pkgs, lib, modulesPath, ... }: +{ pkgs, lib, config, ... }: let - stateVersion = "24.05"; - userName = "myuser"; repoPath = "/srv/nix-docker"; - unstable = import {}; in { - system.stateVersion = stateVersion; imports = [ - (modulesPath + "/virtualisation/proxmox-lxc.nix") - (import "${builtins.fetchTarball https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz}/nixos") - (fetchTarball "https://github.com/nix-community/nixos-vscode-server/tarball/master") - (import ./users.nix { - inherit stateVersion; - inherit userName; - inherit repoPath; - }) - # ./mounts.nix + ./users.nix ]; environment.systemPackages = with pkgs; [ @@ -38,23 +26,9 @@ in # https://nixos.wiki/wiki/Docker virtualisation.docker = { enable = true; - # https://docs.docker.com/engine/security/rootless/ - # rootless = { - # enable = true; - # setSocketVariable = true; - # }; }; - services.vscode-server.enable = true; system.activationScripts.startup = '' echo "Starting Nix-Docker container" ''; - - # Uses rust-based sudo - security.sudo-rs = { - enable = true; - execWheelOnly = false; - wheelNeedsPassword = false; # allows sudo without password for those in the wheel group - }; - } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..064b829 --- /dev/null +++ b/flake.lock @@ -0,0 +1,103 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1734344598, + "narHash": "sha256-wNX3hsScqDdqKWOO87wETUEi7a/QlPVgpC/Lh5rFOuA=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "83ecd50915a09dca928971139d3a102377a8d242", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1734119587, + "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "vscode-server": "vscode-server" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "vscode-server": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729422940, + "narHash": "sha256-DlvJv33ml5UTKgu4b0HauOfFIoDx6QXtbqUF3vWeRCY=", + "owner": "nix-community", + "repo": "nixos-vscode-server", + "rev": "8b6db451de46ecf9b4ab3d01ef76e59957ff549f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-vscode-server", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d77fdff --- /dev/null +++ b/flake.nix @@ -0,0 +1,42 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + vscode-server = { + url = "github:nix-community/nixos-vscode-server"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, ... }@args: + let + inherit (self) outputs; + nixosSystem = args.nixpkgs.lib.nixosSystem; + pkgs = args.nixpkgs.legacyPackages.x86_64-linux; + in + { + nixosConfigurations.lxc = nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inherit pkgs; + }; + modules = [ + (args.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix") + args.vscode-server.nixosModules.default + args.home-manager.nixosModules.default + ./configuration.nix + ({ pkgs, ... }: { + system.stateVersion = "24.11"; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + services.vscode-server.enable = true; + environment.systemPackages = [ pkgs.git ]; + }) + ]; + }; + }; +} diff --git a/git.nix b/git.nix index b166c30..d30ba88 100644 --- a/git.nix +++ b/git.nix @@ -1,8 +1,7 @@ -{ repoPath, ... }: +{ ... }: { programs.git = { enable = true; - extraConfig.safe.directory = "${repoPath}"; extraConfig.credential.helper = "store --file ~/.git-credentials"; userName = "John Lancaster"; userEmail = "32917998+jsl12@users.noreply.github.com"; diff --git a/users.nix b/users.nix index b1edf33..e44575a 100644 --- a/users.nix +++ b/users.nix @@ -1,5 +1,20 @@ -{ stateVersion, userName, repoPath, ... }: +{ config, ... }: +let + userName = "john"; + userOptions = { + home.stateVersion = config.system.stateVersion; + imports = [ ./git.nix ]; + }; + # stateVersion = config.system.stateVersion; +in { + # Uses rust-based sudo + security.sudo-rs = { + enable = true; + execWheelOnly = false; + wheelNeedsPassword = false; # allows sudo without password for those in the wheel group + }; + users.users.${userName} = { isNormalUser = true; extraGroups = [ @@ -13,9 +28,7 @@ home-manager = { useGlobalPkgs = true; - users.${userName} = { - home.stateVersion = stateVersion; - imports = [ (import ./git.nix { inherit repoPath; }) ]; - }; + users.root = userOptions; + users.${userName} = userOptions; }; }