WIP panoptes transition

This commit is contained in:
John Lancaster
2024-12-09 18:00:41 -06:00
parent 41bf8a074e
commit 76dbeeeff1
10 changed files with 154 additions and 137 deletions

36
configuration.nix Normal file
View File

@@ -0,0 +1,36 @@
{ pkgs, userSettings, systemSettings, ... }:
{
# nix.settings.experimental-features = [ "nix-command" "flakes" ];
environment.systemPackages = with pkgs; [
# (pkgs.writeShellScriptBin "nrbs" "sudo nixos-rebuild switch")
# (pkgs.writeShellScriptBin "nrbsu" "sudo nix-channel --update && sudo nixos-rebuild switch")
bash
busybox
git
eza
];
# For SSH access
services.openssh.enable = true;
# Networking stuff
services.avahi = { enable = true; nssmdns4 = true; };
# 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.${userSettings.username} = {
isNormalUser = true;
uid = 1000;
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keyFiles = [ /root/.ssh/authorized_keys ];
};
time.timeZone = "${systemSettings.timeZone}";
networking.hostName = systemSettings.hostName;
}

36
flake.lock generated
View File

@@ -40,11 +40,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1733392399, "lastModified": 1733581040,
"narHash": "sha256-kEsTJTUQfQFIJOcLYFt/RvNxIK653ZkTBIs4DG+cBns=", "narHash": "sha256-Qn3nPMSopRQJgmvHzVqPcE3I03zJyl8cSbgnnltfFDY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d0797a04b81caeae77bcff10a9dde78bc17f5661", "rev": "22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -71,18 +71,6 @@
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": {
"lastModified": 0,
"narHash": "sha256-kEsTJTUQfQFIJOcLYFt/RvNxIK653ZkTBIs4DG+cBns=",
"path": "/nix/store/nr5nl3zwzl02x3rnikjbry3s5xy7bm1d-source",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1682134069, "lastModified": 1682134069,
"narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=", "narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=",
@@ -120,25 +108,9 @@
} }
}, },
"vscode-server": { "vscode-server": {
"inputs": {
"nixpkgs": "nixpkgs_2",
"vscode-server": "vscode-server_2"
},
"locked": {
"lastModified": 1,
"narHash": "sha256-IWEQNW6HVBCztzSy/1SmMTU6R/dyLlnZrJKk9ldJG/I=",
"path": "./nixos/vscode",
"type": "path"
},
"original": {
"path": "./nixos/vscode",
"type": "path"
}
},
"vscode-server_2": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1729422940, "lastModified": 1729422940,

View File

@@ -1,5 +1,5 @@
{ {
description = "Loki flake config"; description = "Panoptes flake config";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@@ -8,7 +8,7 @@
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
vscode-server.url = "path:./nixos/vscode"; vscode-server.url = "github:nix-community/nixos-vscode-server";
}; };
outputs = { outputs = {
@@ -19,61 +19,65 @@
... ...
} @ inputs: } @ inputs:
let let
stateVersion = "24.11";
inherit (self) outputs; inherit (self) outputs;
nixosSystem = inputs.nixpkgs.lib.nixosSystem;
userSettings = rec {
username = "panoptes";
gitUserName = "John Lancaster";
gitUserEmail = "32917998+jsl12@users.noreply.github.com";
# gitUserEmail = "asdfasdf@asdf.com";
};
systemSettings = rec {
hostName = "panoptes-nix";
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
stateVersion = "24.05";
timeZone = "America/Chicago"; timeZone = "America/Chicago";
hostname = "loki"; locale = "en_US.UTF-8";
lokiPort = 3100; };
lokiUser = "loki";
lokiPath = "/srv/loki"; pkgs = inputs.nixpkgs.legacyPackages.${systemSettings.system};
pkgs-stable = inputs.nixpkgs-stable.legacyPackages.${systemSettings.system};
in in
{ {
nixosModules.default = ./nixosModules;
nixosConfigurations = { nixosConfigurations = {
${hostname} = nixpkgs.lib.nixosSystem { "${systemSettings.hostName}" = nixosSystem {
specialArgs = {inherit inputs outputs;}; system = systemSettings.system;
specialArgs = {
inherit inputs;
inherit outputs;
inherit userSettings;
inherit systemSettings;
};
modules = [ modules = [
./nixos/configuration.nix # > Our main nixos configuration file < ./configuration.nix # > Our main nixos configuration file <
"${nixpkgs}/nixos/modules/virtualisation/proxmox-lxc.nix" "${inputs.nixpkgs}/nixos/modules/virtualisation/proxmox-lxc.nix"
({ ... }: { ({ ... }: {
nixpkgs.hostPlatform = "${system}";
system.stateVersion = "${stateVersion}"; system.stateVersion = "${stateVersion}";
time.timeZone = "${timeZone}"; services.vscode-server.enable = true;
environment.systemPackages = [
(pkgs.writeShellScriptBin "nfs" ''
sudo nixos-rebuild switch --flake git+file://${lokiPath}#${hostname}
'')
];
})
(import ./nixos/loki.nix {
inherit pkgs;
inherit lokiPort;
inherit lokiUser;
inherit lokiPath;
}) })
inputs.vscode-server.nixosModules.default
]; ];
}; };
}; };
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
homeConfigurations = { homeConfigurations = {
useGlobalPkgs = true; useGlobalPkgs = true;
"root@${hostname}" = home-manager.lib.homeManagerConfiguration { "panoptes@panoptes-nix" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system}; inherit pkgs stateVersion;
extraSpecialArgs = {inherit inputs outputs;}; specialArgs = {
modules = [(import ./home-manager/git.nix { repoPath = "${lokiPath}"; })]; inherit inputs;
inherit outputs;
inherit userSettings;
inherit systemSettings;
}; };
# 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 = [ modules = [
(import ./home-manager/home.nix { user = "${lokiUser}"; repoPath = "${lokiPath}"; }) ./home.nix
(import ./home-manager/git.nix { repoPath = "${lokiPath}"; }) # ({...}: {home.stateVersion = "${stateVersion}";})
]; ];
}; };
}; };

View File

@@ -1,10 +0,0 @@
{ 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";
};
}

View File

@@ -1,9 +0,0 @@
{ user, repoPath, ... }:
{
programs.home-manager.enable = true;
home = {
stateVersion = "24.05";
username = "${user}";
homeDirectory = "${repoPath}";
};
}

41
home.nix Normal file
View File

@@ -0,0 +1,41 @@
{
pkgs,
systemSettings,
userSettings,
...
}:
let
homePath = "/srv/panoptes";
repoURL = "https://gitea.john-stream.com/john/loki-nix";
repoBranch = "reorg";
in
{
nixpkgs.config.allowUnfree = true;
programs.home-manager.enable = true;
programs.git = {
enable = true;
extraConfig.credential.helper = "store --file ~/.git-credentials";
userName = "${userSettings.gitUserName}";
userEmail = "${userSettings.gitUserEmail}";
extraConfig.safe.directory = "${homePath}";
};
programs.bash.enable = true;
programs.ssh.enable = true;
home = {
homeDirectory = "${homePath}";
packages = [
(pkgs.writeShellScriptBin "nfs" ''
sudo nixos-rebuild switch --flake ${homePath}#${hostName} --impure
'')
(pkgs.writeShellScriptBin "init-panoptes" ''
sudo -u git clone -b ${repoBranch} ${repoURL} /srv/panoptes
'')
git
];
};
systemd.user.startServices = "sd-switch";
}

View File

@@ -1,26 +0,0 @@
{ pkgs, ... }:
{
nix.settings.experimental-features = [ "nix-command" "flakes" ];
environment.systemPackages = with pkgs; [
(pkgs.writeShellScriptBin "nrbs" "sudo nixos-rebuild switch")
(pkgs.writeShellScriptBin "nrbsu" "sudo nix-channel --update && sudo nixos-rebuild switch")
bash
busybox
git
eza
];
# For SSH access
services.openssh.enable = true;
# Networking stuff
services.avahi = { enable = true; nssmdns4 = true; };
# Uses rust-based sudo
security.sudo-rs = {
enable = true;
execWheelOnly = false;
wheelNeedsPassword = false; # allows sudo without password for those in the wheel group
};
}

View File

@@ -1,14 +0,0 @@
{
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;
})
];
};
};
}

19
nixosModules/default.nix Normal file
View File

@@ -0,0 +1,19 @@
{
pkgs,
config,
lib,
inputs,
outputs,
...
}: {
imports =
[
./services/loki.nix
];
config = {
nix.settings.experimental-features = ["nix-command" "flakes"];
programs.nix-ld.enable = true;
nixpkgs.config.allowUnfree = true;
};
}

View File

@@ -1,9 +1,13 @@
{ pkgs, lokiPort ? 3100, ... }: { pkgs, config, ... }:
{ {
networking.firewall.allowedTCPPorts = [ lokiPort ]; networking.firewall.allowedTCPPorts = [
config.services.loki.configuration.server.http_listen_port
];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(pkgs.writeShellScriptBin "loki-check" "curl http://localhost:${builtins.toString lokiPort}/ready") (pkgs.writeShellScriptBin "loki-check" ''
curl http://localhost:${config.services.loki.configuration.server.http_listen_port}/ready
'')
(pkgs.writeShellScriptBin "loki-logs" "journalctl -b -u loki.service -n 10") (pkgs.writeShellScriptBin "loki-logs" "journalctl -b -u loki.service -n 10")
]; ];
@@ -12,7 +16,7 @@
user = "loki"; user = "loki";
configuration = { configuration = {
server.http_listen_port = lokiPort; server.http_listen_port = 3100;
# server.grpc_listen_port = 9096; # server.grpc_listen_port = 9096;
auth_enabled = false; auth_enabled = false;