2022-08-28 05:58:42 +02:00
|
|
|
{
|
|
|
|
description = "Dibbler samspleisebod";
|
|
|
|
|
|
|
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
2022-08-28 09:39:07 +02:00
|
|
|
{
|
|
|
|
overlays.default = final: prev: {
|
|
|
|
dibbler = prev.callPackage ./nix/dibbler.nix { };
|
|
|
|
};
|
|
|
|
} //
|
|
|
|
|
2022-08-28 05:58:42 +02:00
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
2022-08-28 09:39:07 +02:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [ self.overlays.default ];
|
|
|
|
};
|
|
|
|
in {
|
2022-08-28 05:58:42 +02:00
|
|
|
packages = rec {
|
2022-08-28 09:39:07 +02:00
|
|
|
dibbler = pkgs.dibbler;
|
|
|
|
# dibblerCross = pkgs.pkgsCross.aarch64-multiplatform.dibbler;
|
2022-08-28 05:58:42 +02:00
|
|
|
default = dibbler;
|
|
|
|
};
|
|
|
|
apps = rec {
|
|
|
|
dibbler = flake-utils.lib.mkApp {
|
|
|
|
drv = self.packages.${system}.dibbler;
|
|
|
|
};
|
|
|
|
default = dibbler;
|
|
|
|
};
|
|
|
|
}
|
2022-08-28 09:39:07 +02:00
|
|
|
) //
|
|
|
|
|
|
|
|
{
|
|
|
|
nixosModules.default = { config, pkgs, ... }: let
|
|
|
|
inherit (nixpkgs.legacyPackages."x86_64-linux") lib;
|
|
|
|
cfg = config.services.dibbler;
|
|
|
|
in {
|
|
|
|
options.services.dibbler = {
|
|
|
|
package = lib.mkPackageOption pkgs "dibbler" { };
|
|
|
|
config = lib.mkOption {
|
|
|
|
default = ./conf.py;
|
|
|
|
};
|
|
|
|
};
|
2023-01-29 03:53:13 +01:00
|
|
|
|
|
|
|
config = let
|
|
|
|
screen = "${pkgs.screen}/bin/screen";
|
|
|
|
in {
|
2022-08-28 09:39:07 +02:00
|
|
|
nixpkgs.overlays = [ self.overlays.default ];
|
|
|
|
|
2023-01-29 03:53:13 +01:00
|
|
|
boot = {
|
|
|
|
consoleLogLevel = 0;
|
|
|
|
enableContainers = false;
|
|
|
|
loader.grub.enable = false;
|
2022-08-28 09:39:07 +02:00
|
|
|
};
|
2023-01-29 03:23:33 +01:00
|
|
|
|
2023-01-29 03:53:13 +01:00
|
|
|
users = {
|
|
|
|
groups.dibbler = { };
|
|
|
|
users.dibbler = {
|
|
|
|
group = "dibbler";
|
|
|
|
isNormalUser = true;
|
|
|
|
shell = "${screen} -x dibbler";
|
|
|
|
};
|
|
|
|
};
|
2023-01-29 03:23:33 +01:00
|
|
|
|
2023-01-29 03:53:13 +01:00
|
|
|
systemd.services.screen-daemon = {
|
|
|
|
description = "Dibbler service screen";
|
|
|
|
wantedBy = [ "default.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStartPre = "-${screen} -X -S dibbler kill";
|
|
|
|
ExecStart = "${screen} -dmS dibbler -O -l /home/dibbler/dibbler/text_based.py";
|
|
|
|
ExecStartPost = "${screen} -X -S dibbler width 42 80";
|
|
|
|
User = "dibbler";
|
|
|
|
Group = "dibbler";
|
|
|
|
Type = "forking";
|
|
|
|
RemainAfterExit = false;
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "5s";
|
|
|
|
SuccessExitStatus = 1;
|
|
|
|
};
|
|
|
|
};
|
2023-01-29 03:23:33 +01:00
|
|
|
|
2023-01-29 03:53:13 +01:00
|
|
|
# https://github.com/NixOS/nixpkgs/issues/84105
|
|
|
|
systemd.services."serial-getty@ttyUSB0" = {
|
|
|
|
enable = true;
|
|
|
|
wantedBy = [ "getty.target" ];
|
|
|
|
serviceConfig.Restart = "always";
|
|
|
|
};
|
2022-08-28 09:39:07 +02:00
|
|
|
|
2023-01-29 03:53:13 +01:00
|
|
|
services = {
|
|
|
|
openssh = {
|
|
|
|
enable = true;
|
|
|
|
permitRootLogin = "yes";
|
|
|
|
};
|
2022-08-28 09:39:07 +02:00
|
|
|
|
2023-01-29 03:53:13 +01:00
|
|
|
getty.autologinUser = lib.mkForce "dibbler";
|
|
|
|
udisks2.enable = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.logRefusedConnections = false;
|
|
|
|
console.keyMap = "no";
|
|
|
|
programs.command-not-found.enable = false;
|
|
|
|
i18n.supportedLocales = [ "en_US.UTF-8/UTF-8" ];
|
2022-08-28 09:39:07 +02:00
|
|
|
environment.noXlibs = true;
|
2023-01-29 03:53:13 +01:00
|
|
|
|
|
|
|
documentation = {
|
|
|
|
info.enable = false;
|
|
|
|
man.enable = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
security = {
|
|
|
|
polkit.enable = lib.mkForce false;
|
|
|
|
audit.enable = false;
|
|
|
|
};
|
2022-08-28 09:39:07 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
} //
|
|
|
|
|
|
|
|
{
|
|
|
|
nixosConfigurations.skrot = nixpkgs.lib.nixosSystem {
|
|
|
|
system = "aarch64-linux";
|
|
|
|
modules = [
|
|
|
|
(nixpkgs + "/nixos/modules/installer/sd-card/sd-image-aarch64.nix")
|
|
|
|
self.nixosModules.default
|
|
|
|
({...}: {
|
|
|
|
system.stateVersion = "22.05";
|
2023-01-29 03:53:13 +01:00
|
|
|
|
2022-08-28 09:39:07 +02:00
|
|
|
networking = {
|
|
|
|
hostName = "skrot";
|
|
|
|
domain = "pvv.ntnu.no";
|
2023-01-29 03:23:33 +01:00
|
|
|
nameservers = [ "129.241.0.200" "129.241.0.201" ];
|
|
|
|
defaultGateway = "129.241.210.129";
|
|
|
|
interfaces.eth0 = {
|
|
|
|
useDHCP = false;
|
2023-01-29 03:53:13 +01:00
|
|
|
ipv4.addresses = [{
|
|
|
|
address = "129.241.210.235";
|
|
|
|
prefixLength = 25;
|
|
|
|
}];
|
2023-01-29 03:23:33 +01:00
|
|
|
};
|
2022-08-28 09:39:07 +02:00
|
|
|
};
|
2023-01-29 03:23:33 +01:00
|
|
|
# services.resolved.enable = true;
|
|
|
|
# systemd.network.enable = true;
|
|
|
|
# systemd.network.networks."30-network" = {
|
|
|
|
# matchConfig.Name = "*";
|
|
|
|
# DHCP = "no";
|
|
|
|
# address = [ "129.241.210.235/25" ];
|
|
|
|
# gateway = [ "129.241.210.129" ];
|
|
|
|
# };
|
2022-08-28 09:39:07 +02:00
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
images.skrot = self.nixosConfigurations.skrot.config.system.build.sdImage;
|
|
|
|
};
|
2022-08-28 05:58:42 +02:00
|
|
|
}
|