From f92f5bbe1ba62d184fda7e210fb4a735975d2207 Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Medina Date: Fri, 27 Oct 2023 16:29:04 +0100 Subject: [PATCH] nitrokey-firmware: migrate to monorepo Co-authored-by: Auguste Baum --- flake.lock | 57 +++++++++++++++++- flake.nix | 6 +- pkgs/default.nix | 13 ++++ pkgs/nitrokey-firmware/.gitignore | 1 - pkgs/nitrokey-firmware/default.nix | 35 +++++++++++ pkgs/nitrokey-firmware/flake.lock | 96 ------------------------------ pkgs/nitrokey-firmware/flake.nix | 49 --------------- pkgs/nitrokey-firmware/overlay.nix | 20 ------- 8 files changed, 108 insertions(+), 169 deletions(-) delete mode 100644 pkgs/nitrokey-firmware/.gitignore create mode 100644 pkgs/nitrokey-firmware/default.nix delete mode 100644 pkgs/nitrokey-firmware/flake.lock delete mode 100644 pkgs/nitrokey-firmware/flake.nix delete mode 100644 pkgs/nitrokey-firmware/overlay.nix diff --git a/flake.lock b/flake.lock index b6e68b7bf..fe046132f 100644 --- a/flake.lock +++ b/flake.lock @@ -20,6 +20,24 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1695132891, @@ -56,11 +74,33 @@ "inputs": { "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "sops-nix": "sops-nix", - "systems": "systems", + "systems": "systems_2", "treefmt-nix": "treefmt-nix" } }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698372675, + "narHash": "sha256-xjbPB/l68F+eKjWYlD4gio/fHuq2YAe/QVez+ZJnrPQ=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "683fc51ea4e3282e856b215afd830ac9b39e5c7a", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "sops-nix": { "inputs": { "nixpkgs": [ @@ -83,6 +123,21 @@ } }, "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { "locked": { "lastModified": 1680978846, "narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=", diff --git a/flake.nix b/flake.nix index 938313ef3..61055e06f 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,8 @@ inputs.flake-utils.inputs.systems.follows = "systems"; inputs.treefmt-nix.url = "github:numtide/treefmt-nix"; inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; + inputs.rust-overlay.url = "github:oxalica/rust-overlay"; + inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; inputs.sops-nix.url = "github:Mic92/sops-nix"; inputs.sops-nix.inputs.nixpkgs.follows = "nixpkgs"; @@ -20,7 +22,7 @@ treefmt-nix, sops-nix, ... - }: + } @ inputs: with builtins; let inherit (nixpkgs.lib) @@ -50,7 +52,7 @@ inherit (pkgs) lib; inherit callPackage; }; - result = (import ./pkgs/by-name args) // (import ./pkgs args); + result = (import ./pkgs/by-name args) // (import ./pkgs (args // {inherit inputs;})); in result; diff --git a/pkgs/default.nix b/pkgs/default.nix index a2e081554..e790e9b22 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,6 +1,7 @@ { lib, callPackage, + inputs, }: let self = rec { # LiberaForms is intentionally disabled. @@ -28,6 +29,18 @@ pretalx-venueless pretalx-public-voting ; + + # Broken packages: + # - nitrokey-3 + # - nitrokey-fido2 + + inherit + (lib.recurseIntoAttrs (callPackage ./nitrokey-firmware {inherit inputs;})) + nitrokey-storage + nitrokey-pro + nitrokey-start + nitrokey-trng-rs232 + ; }; in self diff --git a/pkgs/nitrokey-firmware/.gitignore b/pkgs/nitrokey-firmware/.gitignore deleted file mode 100644 index d6944e3dd..000000000 --- a/pkgs/nitrokey-firmware/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/result* diff --git a/pkgs/nitrokey-firmware/default.nix b/pkgs/nitrokey-firmware/default.nix new file mode 100644 index 000000000..f2c6d2914 --- /dev/null +++ b/pkgs/nitrokey-firmware/default.nix @@ -0,0 +1,35 @@ +{inputs}: let + system = "x86_64-linux"; + overlays = [inputs.rust-overlay.overlays.default]; + pkgs = import inputs.nixpkgs { + inherit system overlays; + }; + pkgsArm = import inputs.nixpkgs { + inherit system overlays; + crossSystem.config = "arm-none-eabi"; + config.allowUnfree = true; # nitrokey-fido2 → pynitrokey → nrfutil + }; + pkgsAvr = import inputs.nixpkgs { + inherit system overlays; + crossSystem.config = "avr"; + }; +in { + nitrokey-3 = pkgs.callPackage ./devices/nitrokey-3.nix ( + let + rust = pkgs.rust-bin.stable.latest.default.override { + extensions = ["llvm-tools-preview"]; + targets = ["thumbv8m.main-none-eabi"]; + }; + in { + rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform { + rustc = rust; + cargo = rust; + }); + } + ); + nitrokey-storage = pkgs.callPackage ./devices/nitrokey-storage.nix {}; + nitrokey-fido2 = pkgsArm.callPackage ./devices/nitrokey-fido2.nix {}; + nitrokey-pro = pkgsArm.callPackage ./devices/nitrokey-pro.nix {}; + nitrokey-start = pkgsArm.callPackage ./devices/nitrokey-start.nix {}; + nitrokey-trng-rs232 = pkgsAvr.callPackage ./devices/nitrokey-trng-rs232.nix {}; +} diff --git a/pkgs/nitrokey-firmware/flake.lock b/pkgs/nitrokey-firmware/flake.lock deleted file mode 100644 index 076fc90f4..000000000 --- a/pkgs/nitrokey-firmware/flake.lock +++ /dev/null @@ -1,96 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1695132891, - "narHash": "sha256-cJR9AFHmt816cW/C9necLJyOg/gsnkvEeFAfxgeM1hc=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "8b5ab8341e33322e5b66fb46ce23d724050f6606", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "rev": "8b5ab8341e33322e5b66fb46ce23d724050f6606", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1681358109, - "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1698199907, - "narHash": "sha256-n8RtHBIb0rLuYs4RDehW6mj6r6Yam/ODY1af/VCcurw=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "22b8d29fd22cfaa2c311e0d6fd8a0ed9c2a1152b", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/pkgs/nitrokey-firmware/flake.nix b/pkgs/nitrokey-firmware/flake.nix deleted file mode 100644 index c21a0102f..000000000 --- a/pkgs/nitrokey-firmware/flake.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/8b5ab8341e33322e5b66fb46ce23d724050f6606"; - rust-overlay.url = "github:oxalica/rust-overlay"; - }; - - outputs = { - self, - nixpkgs, - rust-overlay, - }: { - overlays.default = import ./overlay.nix; - - packages = { - x86_64-linux = let - system = "x86_64-linux"; - overlays = [rust-overlay.overlays.default self.overlays.default]; - pkgs = import nixpkgs { - inherit system overlays; - }; - pkgsArm = import nixpkgs { - inherit system overlays; - crossSystem.config = "arm-none-eabi"; - config.allowUnfree = true; # nitrokey-fido2 → pynitrokey → nrfutil - }; - pkgsAvr = import nixpkgs { - inherit system overlays; - crossSystem.config = "avr"; - }; - in { - inherit - (pkgs) - nitrokey-3 - nitrokey-storage - ; - inherit - (pkgsArm) - nitrokey-fido2 - nitrokey-pro - nitrokey-start - ; - inherit - (pkgsAvr) - nitrokey-trng-rs232 - ; - }; - }; - }; -} diff --git a/pkgs/nitrokey-firmware/overlay.nix b/pkgs/nitrokey-firmware/overlay.nix deleted file mode 100644 index b4bf5c3ae..000000000 --- a/pkgs/nitrokey-firmware/overlay.nix +++ /dev/null @@ -1,20 +0,0 @@ -final: prev: { - nitrokey-3 = prev.callPackage ./devices/nitrokey-3.nix ( - let - rust = prev.rust-bin.stable.latest.default.override { - extensions = ["llvm-tools-preview"]; - targets = ["thumbv8m.main-none-eabi"]; - }; - in { - rustPlatform = prev.recurseIntoAttrs (prev.makeRustPlatform { - rustc = rust; - cargo = rust; - }); - } - ); - nitrokey-fido2 = prev.callPackage ./devices/nitrokey-fido2.nix {}; - nitrokey-pro = prev.callPackage ./devices/nitrokey-pro.nix {}; - nitrokey-start = prev.callPackage ./devices/nitrokey-start.nix {}; - nitrokey-storage = prev.callPackage ./devices/nitrokey-storage.nix {}; - nitrokey-trng-rs232 = prev.callPackage ./devices/nitrokey-trng-rs232.nix {}; -}