diff --git a/default.nix b/default.nix deleted file mode 100644 index 2feb244..0000000 --- a/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ pkgs ? import { } }: -{ - dibbler = pkgs.callPackage ./nix/dibbler.nix { }; -} diff --git a/flake.lock b/flake.lock index 3f5c267..4c928a4 100644 --- a/flake.lock +++ b/flake.lock @@ -5,31 +5,32 @@ "systems": "systems" }, "locked": { - "lastModified": 1692799911, - "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" + "id": "flake-utils", + "type": "indirect" } }, "nixpkgs": { "locked": { - "lastModified": 1693145325, - "narHash": "sha256-Gat9xskErH1zOcLjYMhSDBo0JTBZKfGS0xJlIRnj6Rc=", + "lastModified": 1742288794, + "narHash": "sha256-Txwa5uO+qpQXrNG4eumPSD+hHzzYi/CdaM80M9XRLCo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cddebdb60de376c1bdb7a4e6ee3d98355453fe56", + "rev": "b6eaf97c6960d97350c584de1b6dcff03c9daf42", "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { diff --git a/flake.nix b/flake.nix index 499a8de..afdb54e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,77 +1,65 @@ { description = "Dibbler samspleisebod"; - inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: let + outputs = { self, nixpkgs, flake-utils }: let + inherit (nixpkgs) lib; + + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + forAllSystems = f: lib.genAttrs systems (system: let pkgs = nixpkgs.legacyPackages.${system}; - in { - packages = { + in f system pkgs); + in { + packages = forAllSystems (system: pkgs: { default = self.packages.${system}.dibbler; dibbler = pkgs.callPackage ./nix/dibbler.nix { - python3Packages = pkgs.python311Packages; + python3Packages = pkgs.python312Packages; }; - }; + skrot = self.nixosConfigurations.skrot.config.system.build.sdImage; + }); - apps = { + apps = forAllSystems (system: pkgs: { default = self.apps.${system}.dibbler; dibbler = flake-utils.lib.mkApp { drv = self.packages.${system}.dibbler; }; - }; + }); - devShells = { - default = self.devShells.${system}.dibbler; - dibbler = pkgs.mkShell { - packages = with pkgs; [ - python311Packages.black - ruff - ]; + overlays = { + default = self.overlays.dibbler; + dibbler = final: prev: { + inherit (self.packages.${prev.system}) dibbler; }; }; - }) - // - - { - # Note: using the module requires that you have applied the - # overlay first + devShells = forAllSystems (system: pkgs: { + default = self.devShells.${system}.dibbler; + dibbler = pkgs.callPackage ./nix/shell.nix { + python3Packages = pkgs.python312Packages; + }; + }); + + # Note: using the module requires that you have applied the overlay first nixosModules.default = import ./nix/module.nix; - images.skrot = self.nixosConfigurations.skrot.config.system.build.sdImage; - - nixosConfigurations.skrot = nixpkgs.lib.nixosSystem { + nixosConfigurations.skrot = nixpkgs.lib.nixosSystem (rec { system = "aarch64-linux"; + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.dibbler ]; + }; 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"; - nameservers = [ "129.241.0.200" "129.241.0.201" ]; - defaultGateway = "129.241.210.129"; - interfaces.eth0 = { - useDHCP = false; - ipv4.addresses = [{ - address = "129.241.210.235"; - prefixLength = 25; - }]; - }; - }; - # 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" ]; - # }; - }) + ./nix/skrott.nix ]; - }; + }); }; } diff --git a/nix/dibbler.nix b/nix/dibbler.nix index 527b7ba..5780eb1 100644 --- a/nix/dibbler.nix +++ b/nix/dibbler.nix @@ -4,7 +4,7 @@ }: python3Packages.buildPythonApplication { pname = "dibbler"; - version = "unstable-2021-09-07"; + version = "unstable"; src = lib.cleanSource ../.; format = "pyproject"; diff --git a/nix/module.nix b/nix/module.nix index 69aa1a1..826b5ee 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -2,15 +2,20 @@ cfg = config.services.dibbler; in { options.services.dibbler = { + enable = lib.mkEnableOption "dibbler, the little kiosk computer"; + package = lib.mkPackageOption pkgs "dibbler" { }; + config = lib.mkOption { + type = lib.types.path; + description = "Path to the configuration file."; default = ../conf.py; }; }; config = let screen = "${pkgs.screen}/bin/screen"; - in { + in lib.mkIf cfg.enable { boot = { consoleLogLevel = 0; enableContainers = false; @@ -69,7 +74,7 @@ in { console.keyMap = "no"; programs.command-not-found.enable = false; i18n.supportedLocales = [ "en_US.UTF-8/UTF-8" ]; - environment.noXlibs = true; + # environment.noXlibs = true; documentation = { info.enable = false; diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..d62f15d --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,12 @@ +{ + mkShell, + python3Packages, + ruff, +}: + +mkShell { + packages = [ + python3Packages.black + ruff + ]; +} diff --git a/nix/skrott.nix b/nix/skrott.nix new file mode 100644 index 0000000..516d718 --- /dev/null +++ b/nix/skrott.nix @@ -0,0 +1,27 @@ +{...}: { + system.stateVersion = "25.05"; + + services.dibbler.enable = true; + + networking = { + hostName = "skrot"; + domain = "pvv.ntnu.no"; + nameservers = [ "129.241.0.200" "129.241.0.201" ]; + defaultGateway = "129.241.210.129"; + interfaces.eth0 = { + useDHCP = false; + ipv4.addresses = [{ + address = "129.241.210.235"; + prefixLength = 25; + }]; + }; + }; + # 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" ]; + # }; +} diff --git a/pyproject.toml b/pyproject.toml index e45113f..9b9dbb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ classifiers = [ ] dependencies = [ "SQLAlchemy >= 2.0, <2.1", - "brother-ql", + # "brother-ql", "matplotlib", "psycopg2 >= 2.8, <2.10", "python-barcode",