From a6348adef138e7b70ff7df333fe191a8a141de71 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:16:26 +0000 Subject: [PATCH] working flakes --- configuration.nix | 17 ++---- flake.lock | 130 ++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 67 ++++++++++++++++++++++++ home.nix | 9 ++++ vscode.nix | 14 +++++ 5 files changed, 223 insertions(+), 14 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home.nix create mode 100644 vscode.nix diff --git a/configuration.nix b/configuration.nix index fd3949b..7ada902 100644 --- a/configuration.nix +++ b/configuration.nix @@ -8,12 +8,11 @@ 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 ./loki.nix { inherit pkgs; inherit userName; }) ]; - time.timeZone = "America/Chicago"; + # time.timeZone = "America/Chicago"; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; environment.systemPackages = with pkgs; [ (pkgs.writeShellScriptBin "nrbs" "sudo nixos-rebuild switch") @@ -30,20 +29,10 @@ in # Networking stuff services.avahi = { enable = true; nssmdns4 = true; }; - services.vscode-server.enable = true; - # Uses rust-based sudo security.sudo-rs = { enable = true; execWheelOnly = false; wheelNeedsPassword = false; # allows sudo without password for those in the wheel group }; - - home-manager = { - useGlobalPkgs = true; - users.root = { - home.stateVersion = stateVersion; - imports = [ (import ./git.nix { inherit repoPath; }) ]; - }; - }; } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..88db3e9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,130 @@ +{ + "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": 1733484277, + "narHash": "sha256-i5ay20XsvpW91N4URET/nOc0VQWOAd4c4vbqYtcH8Rc=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "d00c6f6d0ad16d598bf7e2956f52c1d9d5de3c3a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1733392399, + "narHash": "sha256-kEsTJTUQfQFIJOcLYFt/RvNxIK653ZkTBIs4DG+cBns=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d0797a04b81caeae77bcff10a9dde78bc17f5661", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1733412085, + "narHash": "sha256-FillH0qdWDt/nlO6ED7h4cmN+G9uXwGjwmCnHs0QVYM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4dc2fc4e62dbf62b84132fe526356fbac7b03541", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-24.11", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1682134069, + "narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fd901ef4bf93499374c5af385b2943f5801c0833", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable", + "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_2" + }, + "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..518afbc --- /dev/null +++ b/flake.nix @@ -0,0 +1,67 @@ +{ + description = "Loki flake config"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + nixpkgs-stable.url = "nixpkgs/nixos-24.11"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + vscode-server.url = "github:nix-community/nixos-vscode-server"; + }; + + outputs = { + self, + nixpkgs, + nixpkgs-stable, + home-manager, + vscode-server, + ... + } @ inputs: + let + inherit (self) outputs; + system = "x86_64-linux"; + timeZone = "America/Chicago"; + hostname = "loki"; + lokiUser = "loki"; + lokiPath = "/srv/loki"; + in + { + nixosConfigurations = { + # FIXME replace with your hostname + ${hostname} = nixpkgs.lib.nixosSystem { + system = "${system}"; + # time.timeZone = "${timeZone}"; + specialArgs = {inherit inputs outputs;}; + modules = [ + ./configuration.nix # > Our main nixos configuration file < + vscode-server.nixosModules.default + ({ config, pkgs, ... }: {services.vscode-server.enable = true;}) + ]; + }; + }; + + # Standalone home-manager configuration entrypoint + # Available through 'home-manager --flake .#your-username@your-hostname' + homeConfigurations = { + useGlobalPkgs = true; + "root@${hostname}" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + extraSpecialArgs = {inherit inputs outputs;}; + modules = [(import ./git.nix { repoPath = "${lokiPath}"; })]; + }; + + # FIXME replace with your username@hostname + "${lokiUser}@${hostname}" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + extraSpecialArgs = {inherit inputs outputs;}; + # > Our main home-manager configuration file < + modules = [ + (import ./home.nix { user = "${lokiUser}"; repoPath = "${lokiPath}"; }) + (import ./git.nix { repoPath = "${lokiPath}"; }) + ]; + }; + }; + }; +} \ No newline at end of file diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..8e013c6 --- /dev/null +++ b/home.nix @@ -0,0 +1,9 @@ +{ user, repoPath, ... }: +{ + programs.home-manager.enable = true; + home = { + stateVersion = "24.05"; + username = "${user}"; + homeDirectory = "${repoPath}"; + }; +} diff --git a/vscode.nix b/vscode.nix new file mode 100644 index 0000000..7d8ff5c --- /dev/null +++ b/vscode.nix @@ -0,0 +1,14 @@ +{ + inputs.vscode-server.url = "github:nix-community/nixos-vscode-server"; + + outputs = { self, nixpkgs, vscode-server }: { + nixosConfigurations.yourhostname = nixpkgs.lib.nixosSystem { + modules = [ + vscode-server.nixosModules.default + ({ config, pkgs, ... }: { + services.vscode-server.enable = true; + }) + ]; + }; + }; +} \ No newline at end of file