From: Michal Sojka Date: Sat, 27 Nov 2021 14:01:36 +0000 (+0100) Subject: nix: Add flake.nixbang X-Git-Url: https://rtime.felk.cvut.cz/gitweb/sojka/sterm.git/commitdiff_plain/303737eb4e9ef57b6e4e79f3257b37e360b61c9b nix: Add flake.nixbang 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. --- diff --git a/default.nix b/default.nix index 381c79b..1035b9f 100644 --- a/default.nix +++ b/default.nix @@ -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 index 0000000..567877e --- /dev/null +++ b/flake.lock @@ -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 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); + + }; +}