refactor: pull out systems
This commit is contained in:
98
flake.nix
98
flake.nix
@@ -18,7 +18,8 @@
|
||||
}@inputs: let
|
||||
flake = ./.;
|
||||
nixpkgs = nixpkgs-25-05;
|
||||
self-lib = import ./lib { inherit flake self inputs; };
|
||||
overlays = [ self.overlays.default ];
|
||||
self-lib = import ./lib { inherit flake self inputs nixpkgs; };
|
||||
|
||||
buildPostgresqlExtension =
|
||||
pkgs: pkgs.callPackage (import (builtins.path {
|
||||
@@ -369,98 +370,15 @@
|
||||
});
|
||||
};
|
||||
nixosConfigurations = {
|
||||
"devvm|manual|${system}" = import "./nixos/system/devvm|manual" { inherit flake self inputs; };
|
||||
"hemar-test|${system}" = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
({modulesPath, pkgs, lib, ...}: {
|
||||
imports = [
|
||||
self.nixosModules.hectic
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
hectic = {
|
||||
archetype.dev.enable = true;
|
||||
hardware.hetzner-cloud.enable = true;
|
||||
};
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICrbBG+U07f7OKvOxYIGYCaNvyozzxQF+I9Fb5TYZErK yukkop vm-postgres''
|
||||
];
|
||||
|
||||
|
||||
|
||||
services.postgresql =
|
||||
let
|
||||
package = pkgs.postgresql_15;
|
||||
in {
|
||||
enable = true;
|
||||
package = package;
|
||||
settings =
|
||||
{
|
||||
port = 64317;
|
||||
listen_addresses = lib.mkForce "*";
|
||||
shared_preload_libraries = "";
|
||||
};
|
||||
extensions = [ package.pkgs.hemar ];
|
||||
authentication = builtins.concatStringsSep "\n" [
|
||||
"local all all trust"
|
||||
"host sameuser all 127.0.0.1/32 scram-sha-256"
|
||||
"host sameuser all ::1/128 scram-sha-256"
|
||||
];
|
||||
initialScript = pkgs.writeText "init-sql-script" ''
|
||||
SET log_min_messages TO DEBUG1;
|
||||
SET client_min_messages TO DEBUG1;
|
||||
ALTER DATABASE postgres SET log_min_messages TO DEBUG1;
|
||||
ALTER DATABASE postgres SET client_min_messages TO DEBUG1;
|
||||
CREATE EXTENSION "hemar";
|
||||
|
||||
\i ${./package/c/hemar/test}/mod.sql
|
||||
'';
|
||||
};
|
||||
|
||||
environment.systemPackags = with pkgs; [
|
||||
gdb
|
||||
hectic.nvim-pager
|
||||
(writeScriptBin "check" ''
|
||||
journalctl -u postgresql.service | grep postgresql-post-start | sed 's|psql:/nix/store/[^:]*:[0-9]*: ||' | sed 's|^[^:]*:[^:]*:[^:]*: ||' | grep -v '^\[.*\]' | ${hectic.prettify-log}/bin/prettify-log --color-output
|
||||
'')
|
||||
];
|
||||
programs.zsh.shellAliases = self.lib.sharedShellAliasesForDevVm // {
|
||||
conn = "sudo su postgres -c 'psql -p 64317'";
|
||||
};
|
||||
|
||||
virtualisation = {
|
||||
vmVariant = {
|
||||
systemd.services.fix-root-perms = {
|
||||
description = "Fix root directory permissions";
|
||||
after = [ "local-fs.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.coreutils}/bin/chmod 755 /";
|
||||
};
|
||||
};
|
||||
virtualisation = {
|
||||
diskSize = 1024*6;
|
||||
diskImage = null;
|
||||
forwardPorts = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [
|
||||
80
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
pkgs = import nixpkgs {inherit system; overlays = [ self.overlays.default ];};
|
||||
};
|
||||
"devvm-manual|${system}" = import ./nixos/system/devvm-manual/default.nix { inherit flake self inputs system; };
|
||||
"devvm-hemar|${system}" = import ./nixos/system/devvm-hemar/default.nix { inherit flake self inputs system; };
|
||||
};
|
||||
}) //
|
||||
{
|
||||
legacyPackages = self.lib.forAllSystems (system: import nixpkgs {
|
||||
inherit system overlays;
|
||||
});
|
||||
|
||||
lib = self-lib;
|
||||
overlays.default = import ./overlay { inherit flake self inputs nixpkgs; };
|
||||
nixosModules = import ./nixos/module { inherit flake self inputs nixpkgs; };
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{ flake, inputs, self }: let
|
||||
nixpkgs = inputs.nixpkgs-25-05;
|
||||
{ flake, inputs, self, nixpkgs }: let
|
||||
lib = nixpkgs.lib;
|
||||
recursiveUpdate = nixpkgs.lib.recursiveUpdate;
|
||||
|
||||
@@ -12,7 +11,7 @@
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
forSpecSystemsWithPkgs = supportedSystems: pkgOverlays: f:
|
||||
forSystemsWithPkgs = supportedSystems: pkgOverlays: f:
|
||||
builtins.foldl' (
|
||||
acc: system: let
|
||||
pkgs = import nixpkgs {
|
||||
@@ -28,7 +27,7 @@
|
||||
) {}
|
||||
supportedSystems;
|
||||
|
||||
forAllSystemsWithPkgs = pkgOverlays: f: forSpecSystemsWithPkgs commonSystems pkgOverlays f;
|
||||
forAllSystemsWithPkgs = pkgOverlays: f: forSystemsWithPkgs commonSystems pkgOverlays f;
|
||||
|
||||
parseEnv = import ./parse-env.nix;
|
||||
|
||||
@@ -44,7 +43,10 @@
|
||||
else {};
|
||||
in {
|
||||
# -- For all systems --
|
||||
inherit dotEnv minorEnvironment parseEnv forAllSystemsWithPkgs forSpecSystemsWithPkgs commonSystems;
|
||||
inherit dotEnv minorEnvironment parseEnv forAllSystemsWithPkgs forSystemsWithPkgs commonSystems;
|
||||
|
||||
forSystems = systems: nixpkgs.lib.genAttrs systems;
|
||||
forAllSystems = nixpkgs.lib.genAttrs commonSystems;
|
||||
|
||||
shellModules.logs = ''
|
||||
RED='\033[0;31m'
|
||||
@@ -144,6 +146,8 @@ in {
|
||||
paths;
|
||||
in
|
||||
listToAttrs attrList;
|
||||
|
||||
nixpkgs-lib = nixpkgs.lib;
|
||||
} // rec {
|
||||
/* Supplied a directory, reads it's recursive structure into NixOS modules, so
|
||||
that provided a `./module` dir with `module/foo/bar.nix` in it it outputs
|
||||
|
||||
@@ -5,13 +5,11 @@
|
||||
system,
|
||||
...
|
||||
}: let
|
||||
inherit (self.legacyPackages."${system}") pkgs;
|
||||
|
||||
# Use folder name as name of this system
|
||||
name = builtins.baseNameOf ./.;
|
||||
|
||||
in pkgs.lib.nixosSystem {
|
||||
inherit pkgs;
|
||||
in self.lib.nixpkgs-lib.nixosSystem {
|
||||
inherit (self.legacyPackages."${system}") pkgs;
|
||||
modules = [
|
||||
{ networking.hostName = name; }
|
||||
(import ./${name}.nix { inherit flake self inputs; })
|
||||
91
nixos/system/devvm-hemar/devvm-hemar.nix
Normal file
91
nixos/system/devvm-hemar/devvm-hemar.nix
Normal file
@@ -0,0 +1,91 @@
|
||||
{
|
||||
inputs,
|
||||
flake,
|
||||
self
|
||||
}: {
|
||||
modulesPath,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
self.nixosModules.hectic
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
hectic = {
|
||||
archetype.dev.enable = true;
|
||||
hardware.hetzner-cloud.enable = true;
|
||||
};
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICrbBG+U07f7OKvOxYIGYCaNvyozzxQF+I9Fb5TYZErK yukkop vm-postgres''
|
||||
];
|
||||
|
||||
|
||||
|
||||
services.postgresql =
|
||||
let
|
||||
package = pkgs.postgresql_15;
|
||||
in {
|
||||
enable = true;
|
||||
package = package;
|
||||
settings =
|
||||
{
|
||||
port = 64317;
|
||||
listen_addresses = lib.mkForce "*";
|
||||
shared_preload_libraries = "";
|
||||
};
|
||||
extensions = [ package.pkgs.hemar ];
|
||||
authentication = builtins.concatStringsSep "\n" [
|
||||
"local all all trust"
|
||||
"host sameuser all 127.0.0.1/32 scram-sha-256"
|
||||
"host sameuser all ::1/128 scram-sha-256"
|
||||
];
|
||||
initialScript = pkgs.writeText "init-sql-script" ''
|
||||
SET log_min_messages TO DEBUG1;
|
||||
SET client_min_messages TO DEBUG1;
|
||||
ALTER DATABASE postgres SET log_min_messages TO DEBUG1;
|
||||
ALTER DATABASE postgres SET client_min_messages TO DEBUG1;
|
||||
CREATE EXTENSION "hemar";
|
||||
|
||||
\i ${flake}/package/c/hemar/test/mod.sql
|
||||
'';
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
gdb
|
||||
hectic.nvim-pager
|
||||
(writeScriptBin "check" ''
|
||||
journalctl -u postgresql.service | grep postgresql-post-start | sed 's|psql:/nix/store/[^:]*:[0-9]*: ||' | sed 's|^[^:]*:[^:]*:[^:]*: ||' | grep -v '^\[.*\]' | ${hectic.prettify-log}/bin/prettify-log --color-output
|
||||
'')
|
||||
];
|
||||
programs.zsh.shellAliases = self.lib.sharedShellAliasesForDevVm // {
|
||||
conn = "sudo su postgres -c 'psql -p 64317'";
|
||||
};
|
||||
|
||||
virtualisation = {
|
||||
vmVariant = {
|
||||
systemd.services.fix-root-perms = {
|
||||
description = "Fix root directory permissions";
|
||||
after = [ "local-fs.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.coreutils}/bin/chmod 755 /";
|
||||
};
|
||||
};
|
||||
virtualisation = {
|
||||
diskSize = 1024*6;
|
||||
diskImage = null;
|
||||
forwardPorts = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [
|
||||
80
|
||||
];
|
||||
};
|
||||
}
|
||||
17
nixos/system/devvm-manual/default.nix
Normal file
17
nixos/system/devvm-manual/default.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
flake,
|
||||
self,
|
||||
inputs,
|
||||
system,
|
||||
...
|
||||
}: let
|
||||
# Use folder name as name of this system
|
||||
name = builtins.baseNameOf ./.;
|
||||
|
||||
in self.lib.nixpkgs-lib.nixosSystem {
|
||||
inherit (self.legacyPackages."${system}") pkgs;
|
||||
modules = [
|
||||
{ networking.hostName = name; }
|
||||
(import ./${name}.nix { inherit flake self inputs; })
|
||||
];
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
pkgs,
|
||||
modulesPath,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
Reference in New Issue
Block a user