]> rtime.felk.cvut.cz Git - sojka/sterm.git/commitdiff
nix: Add flake.nixbang
authorMichal Sojka <michal.sojka@cvut.cz>
Sat, 27 Nov 2021 14:01:36 +0000 (15:01 +0100)
committerMichal Sojka <michal.sojka@cvut.cz>
Sat, 27 Nov 2021 14:01:36 +0000 (15:01 +0100)
This allows using sterm on a system based on Nix Flakes. You can add
the provided overlay to nixpkgs overlays by putting:

    nixpkgs.overlays = [ sterm.overlay ];

to your NixOS configuration.nix.

default.nix
flake.lock [new file with mode: 0644]
flake.nix [new file with mode: 0644]

index 381c79b3e2260fd552ba6f38d5f08c387963f56f..1035b9f6868e876484183d2b31660425ec845c3a 100644 (file)
@@ -5,6 +5,6 @@
 with pkgs;
 stdenv.mkDerivation {
   name = "sterm";
-  src = builtins.fetchGit { url = ./.; };
+  src = ./.;
   installPhase = "make install PREFIX=$out";
 }
diff --git a/flake.lock b/flake.lock
new file mode 100644 (file)
index 0000000..567877e
--- /dev/null
@@ -0,0 +1,26 @@
+{
+  "nodes": {
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1637875414,
+        "narHash": "sha256-Ica++SXFuLyxX9Q7YxhfZulUif6/gwM8AEQYlUxqSgE=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "3bea86e918d8b54aa49780505d2d4cd9261413be",
+        "type": "github"
+      },
+      "original": {
+        "id": "nixpkgs",
+        "ref": "nixos-21.05",
+        "type": "indirect"
+      }
+    },
+    "root": {
+      "inputs": {
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644 (file)
index 0000000..a99910c
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,36 @@
+{
+  description = "Simple serial terminal";
+
+  # Nixpkgs / NixOS version to use.
+  inputs.nixpkgs.url = "nixpkgs/nixos-21.05";
+
+  outputs = { self, nixpkgs }:
+    let
+
+      # Generate a user-friendly version number.
+      version = builtins.substring 0 8 self.lastModifiedDate;
+
+      # System types to support.
+      supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
+
+      # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
+      forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
+
+      # Nixpkgs instantiated for supported system types.
+      nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
+
+    in
+      {
+
+        # A Nixpkgs overlay.
+        overlay = final: prev: {
+          sterm = (import ./default.nix { pkgs = final; }).overrideAttrs (old: { name = "${old.name}-${version}"; });
+        };
+
+        defaultPackage = forAllSystems (system: (import nixpkgs {
+          inherit system;
+          overlays = [ self.overlay ];
+        }).sterm);
+
+      };
+}