From 39747e544b64d28f741dec1ce7b96361a83d0e8c Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sun, 28 Aug 2022 09:39:07 +0200 Subject: [PATCH] Add SD image to flake --- .gitignore | 4 +-- README.MD | 31 ++++++++++++++++++++++ README.txt | 1 - flake.nix | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 README.MD delete mode 100644 README.txt diff --git a/.gitignore b/.gitignore index d8ccc8d..f295f42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -result/ -result-*/ +result +result-* \ No newline at end of file diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..08b54ab --- /dev/null +++ b/README.MD @@ -0,0 +1,31 @@ +# Dibbler + +EDB-system for PVVVV + +## Nix +### Hvordan kjøre + +`nix run github:Prograrmvarverkstedet/dibbler` + + +### Bygge nytt image + +For å bygge et image trenger du en builder som takler å bygge for arkitekturen du skal lage et image for. + +(Eller be til gudene om at cross compile funker) + +Flaket exposer en modul som autologger inn med en bruker som automatisk kjører dibbler, og setter opp et minimalistisk miljø. + +Før du bygger imaget burde du endre conf.py lokalt til å inneholde instillingene dine. **NB: Denne kommer til å ligge i nix storen.** + +Du kan også endre hvilken conf.py som blir brukt direkte i pakken eller i modulen. + +Se eksempelet for hvordan skrot er satt opp i flake.nix + +### Bygge image for skrot +Skrot har et image definert i flake.nix: + +1. endre conf.py +2. `nix build .#images.skrot` +3. ??? +4. non-profit \ No newline at end of file diff --git a/README.txt b/README.txt deleted file mode 100644 index ef3de00..0000000 --- a/README.txt +++ /dev/null @@ -1 +0,0 @@ -Dibbler, EDB-system for PVVVV diff --git a/flake.nix b/flake.nix index fd61e4b..3e3bae7 100644 --- a/flake.nix +++ b/flake.nix @@ -4,12 +4,22 @@ inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { self, nixpkgs, flake-utils }: + { + overlays.default = final: prev: { + dibbler = prev.callPackage ./nix/dibbler.nix { }; + }; + } // + flake-utils.lib.eachDefaultSystem (system: - let pkgs = nixpkgs.legacyPackages.${system}; in - { + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + }; + in { packages = rec { - dibbler = pkgs.callPackage ./nix/dibbler.nix { }; - # dibblerCross = pkgs.pkgsCross.aarch64-multiplatform.callPackage ./nix/dibbler.nix { }; + dibbler = pkgs.dibbler; + # dibblerCross = pkgs.pkgsCross.aarch64-multiplatform.dibbler; default = dibbler; }; apps = rec { @@ -19,5 +29,60 @@ default = dibbler; }; } - ); + ) // + + { + 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; + }; + }; + config = { + nixpkgs.overlays = [ self.overlays.default ]; + + users.users.dibbler = { + group = "dibbler"; + isNormalUser = true; + shell = "${cfg.package.override { conf = cfg.config; }}/bin/dibbler"; + }; + users.groups.dibbler = { }; + services.getty.autologinUser = lib.mkForce "dibbler"; + + i18n.supportedLocales = ["en_US.UTF-8/UTF-8"]; + documentation.info.enable = false; + documentation.man.enable = false; + programs.command-not-found.enable = false; + security.polkit.enable = lib.mkForce false; + security.audit.enable = false; + services.udisks2.enable = false; + boot.enableContainers = false; + boot.loader.grub.enable = false; + + environment.noXlibs = true; + }; + }; + } // + + { + 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"; + networking = { + hostName = "skrot"; + domain = "pvv.ntnu.no"; + }; + }) + ]; + }; + images.skrot = self.nixosConfigurations.skrot.config.system.build.sdImage; + }; }