2023-06-11 23:09:59 +02:00
|
|
|
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
2023-10-29 17:50:22 +01:00
|
|
|
nixpkgs-stable.url = "github:NixOS/nixpkgs?ref=nixos-23.05";
|
2023-07-10 23:35:56 +02:00
|
|
|
nixpkgs-hashicorp.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
2023-06-11 23:09:59 +02:00
|
|
|
nixinate.url = "github:MagicRB/nixinate";
|
|
|
|
home-manager.url = "github:nix-community/home-manager?ref=master";
|
|
|
|
nixng.url = "github:nix-community/NixNG";
|
|
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
|
|
nil.url = "github:oxalica/nil";
|
2023-06-19 01:14:39 +02:00
|
|
|
uterranix.url = "sourcehut:~magic_rb/uterranix";
|
2023-06-11 23:09:59 +02:00
|
|
|
dwarffs.url = "github:edolstra/dwarffs";
|
2023-07-27 20:57:26 +02:00
|
|
|
haskell-nix.url = "github:input-output-hk/haskell.nix";
|
|
|
|
serokell-nix.url = "github:magicrb/serokell.nix";
|
|
|
|
serokell-nix.inputs.haskell-nix.follows = "haskell-nix";
|
2023-07-10 21:31:17 +02:00
|
|
|
website.url = "sourcehut:~magic_rb/website";
|
2023-09-17 15:00:50 +02:00
|
|
|
microvm.url = "github:astro/microvm.nix";
|
|
|
|
notnft.url = "github:chayleaf/notnft";
|
2023-10-21 17:46:17 +02:00
|
|
|
impermenance.url = "github:MagicRB/impermanence";
|
2023-10-07 17:02:11 +02:00
|
|
|
numen-nix.url = "github:anpandey/numen-nix";
|
2023-10-21 16:34:41 +02:00
|
|
|
hydra.url = "github:t184256/hydra/nix-ca-reprise";
|
2023-10-23 15:09:49 +02:00
|
|
|
nix.url = "github:NixOS/nix";
|
2023-06-11 23:09:59 +02:00
|
|
|
|
2023-06-28 14:17:17 +02:00
|
|
|
disko.url = "github:nix-community/disko";
|
|
|
|
nixos-anywhere.url = "github:numtide/nixos-anywhere";
|
|
|
|
|
2023-06-11 23:09:59 +02:00
|
|
|
tuxedo-rs.url = "github:AaronErhardt/tuxedo-rs";
|
|
|
|
tuxedo-rs.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
|
|
|
tuxedo-nixos.url = "github:blitz/tuxedo-nixos";
|
|
|
|
tuxedo-nixos.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
|
|
|
emacs.url = "sourcehut:~magic_rb/emacs";
|
|
|
|
emacs.flake = false;
|
|
|
|
|
|
|
|
vtermModule.url = "github:akermu/emacs-libvterm";
|
|
|
|
vtermModule.flake = false;
|
|
|
|
|
2023-10-06 15:01:20 +02:00
|
|
|
secret.url = "path:///home/main/dotfiles/secret";
|
2023-06-11 23:09:59 +02:00
|
|
|
secret.flake = false;
|
|
|
|
|
|
|
|
ical2org.url = "git+https://git.sr.ht/~magic_rb/ical2orgpy";
|
|
|
|
ical2org.flake = false;
|
|
|
|
|
|
|
|
udp-over-tcp.url = "github:mullvad/udp-over-tcp";
|
|
|
|
udp-over-tcp.flake = false;
|
|
|
|
};
|
|
|
|
|
2023-06-18 20:07:47 +02:00
|
|
|
outputs = inputs@{ flake-parts, self, secret, ... }:
|
|
|
|
flake-parts.lib.mkFlake { inherit inputs; } ({ config, lib', ... }: {
|
2023-06-11 23:09:59 +02:00
|
|
|
imports = [
|
2023-06-13 23:00:56 +02:00
|
|
|
modules/nixngConfigurations.nix
|
2023-06-18 20:07:47 +02:00
|
|
|
modules/lib_overlays.nix
|
|
|
|
lib/load_secrets.nix
|
2023-06-13 23:00:56 +02:00
|
|
|
|
2023-06-11 23:09:59 +02:00
|
|
|
nixos/systems/omen
|
|
|
|
nixos/systems/heater
|
|
|
|
nixos/systems/toothpick
|
|
|
|
nixos/systems/liveusb
|
2023-06-12 23:25:40 +02:00
|
|
|
nixos/systems/blowhole
|
2023-06-28 14:17:17 +02:00
|
|
|
nixos/systems/altra
|
2023-07-18 20:40:57 +02:00
|
|
|
nixos/systems/gooseberry
|
2023-06-11 23:09:59 +02:00
|
|
|
|
2023-06-13 23:06:10 +02:00
|
|
|
nixng/containers/ingress-blowhole
|
2023-06-19 01:19:55 +02:00
|
|
|
nixng/containers/ingress-toothpick
|
2023-06-13 23:05:35 +02:00
|
|
|
nixng/containers/matrix/mautrix-signal
|
|
|
|
nixng/containers/matrix/mautrix-discord
|
|
|
|
nixng/containers/matrix/mautrix-facebook
|
|
|
|
nixng/containers/matrix/heisenbridge
|
|
|
|
nixng/containers/matrix/synapse
|
2023-06-13 23:05:08 +02:00
|
|
|
nixng/containers/website
|
2023-06-13 23:07:02 +02:00
|
|
|
nixng/containers/home-assistant
|
2023-06-13 23:05:53 +02:00
|
|
|
nixng/containers/email/getmail
|
|
|
|
nixng/containers/email/dovecot.nix
|
|
|
|
nixng/containers/email/postfix
|
2023-06-13 23:07:18 +02:00
|
|
|
nixng/containers/gitea
|
2023-06-13 23:07:31 +02:00
|
|
|
nixng/containers/hydra
|
2023-06-13 23:06:34 +02:00
|
|
|
nixng/containers/syncthing
|
2023-10-24 12:58:54 +02:00
|
|
|
# nixng/containers/minecraft/vanilla
|
|
|
|
# nixng/containers/minecraft/ftb-infinity
|
|
|
|
# nixng/containers/minecraft/ftb-integrations
|
2023-06-13 23:06:34 +02:00
|
|
|
|
2023-06-11 23:09:59 +02:00
|
|
|
overlays/udp-over-tcp.nix
|
|
|
|
overlays/emacsclient-remote
|
|
|
|
overlays/magic-screenshot
|
|
|
|
overlays/emacs-rofi
|
|
|
|
overlays/tree-sitter-grammars.nix
|
|
|
|
overlays/emacs-master-nativecomp
|
2023-06-12 23:25:40 +02:00
|
|
|
overlays/zfs-relmount
|
2023-06-13 23:01:25 +02:00
|
|
|
overlays/mautrix-discord.nix
|
2023-06-13 23:03:01 +02:00
|
|
|
overlays/getmail6
|
2023-06-13 23:02:11 +02:00
|
|
|
overlays/maildrop
|
2023-06-13 23:03:45 +02:00
|
|
|
overlays/courier-unicode.nix
|
2023-06-13 23:04:10 +02:00
|
|
|
overlays/ds3os.nix
|
2023-06-14 12:27:08 +02:00
|
|
|
overlays/terraform-provider-vault.nix
|
2023-06-14 12:22:27 +02:00
|
|
|
overlays/terraform-provider-influxdb-v2.nix
|
2023-06-15 23:02:23 +02:00
|
|
|
overlays/bootloadHID.nix
|
2023-09-03 18:03:47 +02:00
|
|
|
overlays/itp
|
2023-10-07 22:31:24 +02:00
|
|
|
overlays/virtiofsd-zfs
|
2023-10-03 16:55:14 +02:00
|
|
|
overlays/show-files-to-be-deleted
|
2023-10-07 22:40:05 +02:00
|
|
|
overlays/rolling_datasets
|
2023-10-16 14:57:43 +02:00
|
|
|
overlays/ledger-compat
|
2023-06-15 23:04:14 +02:00
|
|
|
|
|
|
|
inputs.uterranix.flakeModule
|
|
|
|
];
|
|
|
|
|
2023-06-18 20:07:47 +02:00
|
|
|
_module.args.lib' =
|
|
|
|
let
|
|
|
|
inherit (inputs.nixpkgs) lib;
|
|
|
|
inherit (inputs.nixpkgs.lib)
|
|
|
|
extend;
|
|
|
|
in
|
|
|
|
lib.foldl (acc: x: acc.extend x) lib (with config.flake.libOverlays; [
|
|
|
|
loadSecrets
|
|
|
|
]);
|
|
|
|
|
2023-06-16 16:43:11 +02:00
|
|
|
flake.hydraJobs =
|
|
|
|
let
|
2023-06-18 20:07:47 +02:00
|
|
|
inherit (lib')
|
2023-06-16 16:43:11 +02:00
|
|
|
mapAttrs;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
nixng = mapAttrs (_: v: v.config.system.build.toplevel) config.flake.nixngConfigurations;
|
|
|
|
nixos = mapAttrs (_: v: v.config.system.build.toplevel) config.flake.nixosConfigurations;
|
2023-10-29 17:52:27 +01:00
|
|
|
packages = mapAttrs (_: v: v.config.system.build.toplevel) config.flake.nixosConfigurations;
|
2023-06-16 16:43:11 +02:00
|
|
|
};
|
|
|
|
|
2023-06-15 23:04:14 +02:00
|
|
|
uterranix.config = [
|
|
|
|
./terranix/default.nix
|
|
|
|
{
|
2023-06-18 20:12:05 +02:00
|
|
|
_module.args.secret = lib'.loadSecrets secret;
|
2023-06-15 23:04:14 +02:00
|
|
|
_module.args.vars = {
|
2023-06-22 23:25:09 +02:00
|
|
|
flake_rev = self.rev or (lib'.warn "No flake revision available, do not deploy containers!" "");
|
|
|
|
flake_sha = self.narHash or (lib'.warn "No flake nar hash available, do not deploy containers!" "");
|
2023-06-18 20:12:05 +02:00
|
|
|
flake_ref = "master";
|
2023-06-19 00:53:38 +02:00
|
|
|
flake_host = "git+https://git.sr.ht/~magic_rb/dotfiles-2.0";
|
2023-06-15 23:04:14 +02:00
|
|
|
};
|
2023-06-29 19:11:39 +02:00
|
|
|
_module.args.config' = config;
|
2023-06-15 23:04:14 +02:00
|
|
|
}
|
2023-06-11 23:09:59 +02:00
|
|
|
];
|
|
|
|
|
2023-06-15 23:04:14 +02:00
|
|
|
uterranix.terraform = pkgs:
|
|
|
|
let
|
|
|
|
hpkgs = inputs.nixpkgs.legacyPackages.${pkgs.stdenv.system}.appendOverlays (with config.flake.overlays; [
|
|
|
|
terraform-provider-vault
|
|
|
|
terraform-provider-influxdb-v2
|
|
|
|
]);
|
|
|
|
in
|
|
|
|
hpkgs.terraform.withPlugins (p: [
|
|
|
|
p.consul
|
|
|
|
p.nomad
|
|
|
|
p.local
|
|
|
|
p.vault
|
|
|
|
p.random
|
|
|
|
p.null
|
|
|
|
p.influxdb-v2
|
2023-06-22 23:25:39 +02:00
|
|
|
p.hcloud
|
2023-06-15 23:04:14 +02:00
|
|
|
] );
|
|
|
|
|
2023-06-11 23:09:59 +02:00
|
|
|
flake.nixosModules = {
|
|
|
|
hashicorp = nixos/modules/hashicorp.nix;
|
2023-06-12 23:25:40 +02:00
|
|
|
hashicorp-envoy = nixos/modules/hashicorp-envoy.nix;
|
|
|
|
telegraf = nixos/modules/telegraf.nix;
|
|
|
|
grafana = nixos/modules/grafana.nix;
|
2023-09-03 18:03:47 +02:00
|
|
|
influx-provisioning = nixos/modules/influx-provisioning.nix;
|
2023-09-17 15:00:50 +02:00
|
|
|
microvm-extras = nixos/modules/microvm-extras.nix;
|
|
|
|
microvm-extras-host = nixos/modules/microvm-extras-host.nix;
|
|
|
|
notnft = nixos/modules/notnft.nix;
|
2023-06-11 23:09:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
flake.apps = inputs.nixpkgs.lib.genAttrs config.systems (system: {
|
2023-06-28 14:17:17 +02:00
|
|
|
nixos-anywhere.program = (inputs.nixos-anywhere.packages.${system}.nixos-anywhere);
|
|
|
|
nixos-anywhere.type = "app";
|
2023-06-11 23:09:59 +02:00
|
|
|
});
|
|
|
|
|
2023-06-16 16:40:38 +02:00
|
|
|
perSystem = { system, pkgs, ... }:
|
|
|
|
{
|
2023-06-16 16:42:40 +02:00
|
|
|
packages =
|
|
|
|
let
|
2023-06-18 20:07:47 +02:00
|
|
|
inherit (lib')
|
2023-06-16 16:42:40 +02:00
|
|
|
attrValues;
|
2023-10-29 17:49:35 +01:00
|
|
|
pkgs' = pkgs.appendOverlays (attrValues config.flake.overlays ++ [
|
|
|
|
inputs.nixng.overlays.default
|
|
|
|
inputs.nix-matlab.overlay
|
|
|
|
]);
|
2023-06-16 16:42:40 +02:00
|
|
|
in
|
|
|
|
{
|
2023-10-29 17:49:35 +01:00
|
|
|
terraform-provider-influxdb-v2 = pkgs'.terraform-providers.influxdb-v2;
|
|
|
|
terraform-provider-vault = pkgs'.terraform-providers.vault;
|
2023-06-16 16:42:40 +02:00
|
|
|
inherit (pkgs')
|
|
|
|
emacsclient-remote
|
|
|
|
emacs-master-nativecomp
|
|
|
|
emacs-rofi
|
|
|
|
getmail6
|
|
|
|
magic-screenshot
|
|
|
|
maildrop
|
|
|
|
zfs-relmount
|
|
|
|
bootloadHID
|
|
|
|
tree-sitter-grammars
|
2023-09-03 18:03:47 +02:00
|
|
|
udp-over-tcp
|
2023-09-16 16:42:21 +02:00
|
|
|
itp
|
2023-11-03 20:23:05 +01:00
|
|
|
rolling_datasets;
|
2023-10-29 17:50:03 +01:00
|
|
|
# ds3os;
|
2023-06-16 16:42:40 +02:00
|
|
|
};
|
|
|
|
|
2023-10-03 16:54:07 +02:00
|
|
|
devShells.default =
|
|
|
|
let
|
|
|
|
unpackSrc = package: pkgs.stdenv.mkDerivation {
|
|
|
|
pname = package.pname;
|
|
|
|
version = package.version;
|
|
|
|
|
|
|
|
src = package.src;
|
|
|
|
|
|
|
|
phases = [ "unpackPhase" "installPhase" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp -r . $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
prepareDeps = pkgs.writeShellScript "prepare-deps.sh" ''
|
|
|
|
cd "$(git rev-parse --show-toplevel)/home-manager/modules/xmonad"
|
|
|
|
mkdir -p .packages
|
|
|
|
|
|
|
|
_rsync_args=("--no-perms" "--no-owner" "--no-group" "--del" "--exclude=.stack-work" "--chmod=ugo=rwX" "-crvP")
|
|
|
|
rsync "''${_rsync_args[@]}" ${unpackSrc pkgs.haskell.packages.ghc946.xmonad}/. .packages/xmonad >/dev/null 2>&1
|
|
|
|
rsync "''${_rsync_args[@]}" ${unpackSrc pkgs.haskell.packages.ghc946.xmonad-contrib}/. .packages/xmonad-contrib >/dev/null 2>&1
|
|
|
|
rsync "''${_rsync_args[@]}" ${unpackSrc pkgs.haskell.packages.ghc946.xmobar}/. .packages/xmobar >/dev/null 2>&1
|
|
|
|
'';
|
|
|
|
stack-wrapped = pkgs.symlinkJoin {
|
|
|
|
name = "stack"; # will be available as the usual `stack` in terminal
|
|
|
|
paths = [ pkgs.stack ];
|
|
|
|
buildInputs = [ pkgs.makeWrapper ];
|
|
|
|
postBuild = ''
|
|
|
|
wrapProgram $out/bin/stack \
|
|
|
|
--run "${prepareDeps}"\
|
|
|
|
--add-flags "\
|
|
|
|
--no-nix \
|
|
|
|
--system-ghc \
|
|
|
|
--no-install-ghc \
|
|
|
|
"
|
|
|
|
'';
|
|
|
|
};
|
2023-10-21 17:25:09 +02:00
|
|
|
|
|
|
|
nix-wrapped = pkgs.writeShellScriptBin "nix" ''
|
|
|
|
pre_lock_hash="$(sha256sum flake-secret.lock | cut -f1 -d' ')"
|
|
|
|
new_args=()
|
|
|
|
i="0"
|
|
|
|
|
|
|
|
flake=0
|
2023-10-23 22:18:15 +02:00
|
|
|
immutable=0
|
|
|
|
|
|
|
|
for arg in "$@" ; do
|
|
|
|
if [[ "$arg" =~ "^git+file://.*$" ]] ; then
|
|
|
|
immutable=1
|
|
|
|
fi
|
|
|
|
done
|
2023-10-21 17:25:09 +02:00
|
|
|
|
|
|
|
for arg in "$@" ; do
|
|
|
|
case "$arg" in
|
2023-10-23 22:18:15 +02:00
|
|
|
build|eval|run)
|
2023-10-21 17:25:09 +02:00
|
|
|
new_args[$i]="$arg"
|
|
|
|
new_args[$(($i + 1))]="--reference-lock-file"
|
|
|
|
new_args[$(($i + 2))]="flake-secret.lock"
|
2023-10-23 22:18:15 +02:00
|
|
|
if [[ "$immutable" != 0 ]] ; then
|
|
|
|
new_args[$(($i + 3))]="--output-lock-file"
|
|
|
|
new_args[$(($i + 4))]="flake-secret.lock"
|
|
|
|
i="$(($i + 2))"
|
|
|
|
fi
|
|
|
|
i="$(($i + 3))"
|
2023-10-21 17:25:09 +02:00
|
|
|
;;
|
|
|
|
flake)
|
|
|
|
new_args[$i]="$arg"
|
|
|
|
i="$(($i + 1))"
|
|
|
|
flake=1
|
|
|
|
;;
|
|
|
|
--*|-*)
|
|
|
|
new_args[$i]="$arg"
|
|
|
|
i="$(($i + 1))"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [[ "$flake" == "1" ]] ; then
|
|
|
|
new_args[$i]="$arg"
|
|
|
|
new_args[$(($i + 1))]="--reference-lock-file"
|
|
|
|
new_args[$(($i + 2))]="flake-secret.lock"
|
|
|
|
new_args[$(($i + 3))]="--output-lock-file"
|
|
|
|
new_args[$(($i + 4))]="flake-secret.lock"
|
|
|
|
i="$(($i + 5))"
|
|
|
|
else
|
|
|
|
new_args[$i]="$arg"
|
|
|
|
i="$(($i + 1))"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2023-10-22 00:34:43 +02:00
|
|
|
( exec -a $0 .nix-unwrapped "''${new_args[@]}" )
|
2023-10-21 17:25:09 +02:00
|
|
|
|
|
|
|
post_lock_hash="$(sha256sum flake-secret.lock | cut -f1 -d' ')"
|
|
|
|
|
|
|
|
if ! [[ "$pre_lock_hash" == "$post_lock_hash" ]] ; then
|
|
|
|
cp flake-secret.lock flake.lock
|
2023-10-22 00:34:43 +02:00
|
|
|
.nix-unwrapped flake lock --override-input secret path:///var/empty
|
2023-10-21 17:25:09 +02:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
nix-with-wrapper = pkgs.symlinkJoin {
|
|
|
|
name = "nix";
|
2023-10-22 00:34:43 +02:00
|
|
|
paths = [ pkgs.nixUnstable ];
|
|
|
|
buildInputs = [ pkgs.makeWrapper ];
|
|
|
|
postBuild = ''
|
|
|
|
mv $out/bin/nix $out/bin/.nix-unwrapped
|
|
|
|
cp ${nix-wrapped}/bin/nix $out/bin/nix
|
|
|
|
'';
|
2023-10-21 17:25:09 +02:00
|
|
|
};
|
2023-10-22 00:34:43 +02:00
|
|
|
nixos-rebuild = pkgs.nixos-rebuild.override { nix = nix-with-wrapper; };
|
2023-10-03 16:54:07 +02:00
|
|
|
in
|
|
|
|
pkgs.mkShell {
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
(pkgs.writeShellScriptBin "update-secret" ''
|
|
|
|
nix flake lock --update-input secret
|
|
|
|
'')
|
2023-10-22 00:34:43 +02:00
|
|
|
nil nix-with-wrapper nixos-rebuild
|
2023-10-03 16:54:07 +02:00
|
|
|
nomad consul vault
|
|
|
|
|
|
|
|
haskell.compiler.ghc946
|
|
|
|
stack-wrapped
|
|
|
|
pkg-config
|
|
|
|
haskell.packages.ghc946.haskell-language-server
|
2023-10-21 17:25:09 +02:00
|
|
|
jq
|
2023-11-04 20:03:12 +01:00
|
|
|
alejandra
|
2023-10-03 16:54:07 +02:00
|
|
|
] ++ (lib.foldl (acc: x: acc ++ x) [] (map (x: pkgs.haskell.packages.ghc946.${x}.buildInputs) [ "gi-pangocairo" "X11" "cairo" "glib" ]));
|
|
|
|
};
|
2023-06-16 16:40:38 +02:00
|
|
|
};
|
|
|
|
|
2023-06-11 23:09:59 +02:00
|
|
|
flake.patches = {
|
|
|
|
hashicorp-nomad.revert-change-consul-si-tokens-to-be-local = patches/0001-Revert-Change-consul-SI-tokens-to-be-local.patch;
|
|
|
|
hashicorp-nomad.add-nix-integration = patches/0001-Add-Nix-integration.patch;
|
2023-06-12 23:25:40 +02:00
|
|
|
hostapd.intel_lar-and-noscan = patches/0001-intel_lar-and-noscan.patch;
|
|
|
|
hostapd.hostapd-2_10-lar = patches/999-hostapd-2.10-lar.patch;
|
|
|
|
hostapd.hostapd-2_10-lar-2 = patches/hostapd-2.10-lar.patch;
|
2023-06-14 12:27:08 +02:00
|
|
|
terraform-provider-nomad.allow-null-in-authMountTuneSchema = patches/vault-provider-Allow-null-in-authMountTuneSchema.patch;
|
2023-06-11 23:09:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
systems = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"armv8-linux"
|
|
|
|
"riscv64-linux"
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|