]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
nix: Convert to flakes
authorMichal Sojka <michal.sojka@cvut.cz>
Sun, 3 Apr 2022 12:22:39 +0000 (14:22 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Sun, 3 Apr 2022 12:22:39 +0000 (14:22 +0200)
We use flake-comapt to keep compatibility the old Nix.

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

index d1e317a06e616f1f51231437c64977a03521442b..b22e926ea4f94a727dab8186d10746f5212d0e28 100644 (file)
@@ -1,36 +1,3 @@
-{
-  nixpkgs ? <nixpkgs>,
-  pkgs ? import nixpkgs {},
-  otherPerlPackages ? []
-}:
-with pkgs;
-let
-  IO-Stty = perlPackages.buildPerlPackage {
-    pname = "IO-Stty";
-    version = "0.04";
-    src = fetchurl {
-      url = "mirror://cpan/authors/id/T/TO/TODDR/IO-Stty-0.04.tar.gz";
-      sha256 = "1hjicqy50mgbippn310k4zclr9ksz05yyg81za3q4gb9m3qhk5aw";
-    };
-  };
-  perlEnv = (perl.withPackages (p: [ p.Expect IO-Stty ] ++ otherPerlPackages));
-in
-{
-  novaboot = stdenv.mkDerivation {
-    name = "novaboot";
-    src = builtins.fetchGit { url = ./.; };
-    buildInputs = [ perlEnv rsync ];
-    installPhase = ''
-    make install DESTDIR=$out PREFIX=
-  '';
-  };
-  novaboot-server = stdenv.mkDerivation {
-    name = "novaboot-server";
-    src = builtins.fetchGit { url = ./.; };
-    nativeBuildInputs = [ perl ];
-    buildInputs = [ rsync ];
-    installPhase = ''
-    make -C server install DESTDIR=$out PREFIX=
-  '';
-  };
-}
+(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
+  src = builtins.fetchGit ./.;
+}).defaultNix
diff --git a/flake.lock b/flake.lock
new file mode 100644 (file)
index 0000000..5fe8f21
--- /dev/null
@@ -0,0 +1,43 @@
+{
+  "nodes": {
+    "flake-utils": {
+      "locked": {
+        "lastModified": 1648297722,
+        "narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1648632716,
+        "narHash": "sha256-kCmnDeiaMsdhfnNKjxdOzwRh2H6eQb8yWAL+nNabC/Y=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "710fed5a2483f945b14f4a58af2cd3676b42d8c8",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644 (file)
index 0000000..75f1e51
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,46 @@
+{
+  description = "novaboot";
+
+  inputs = {
+    # The nixpkgs entry in the flake registry.
+    nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
+    flake-utils.url = "github:numtide/flake-utils";
+  };
+
+  outputs = { self, nixpkgs, flake-utils }:
+    flake-utils.lib.eachDefaultSystem (system:
+      let
+        pkgs = nixpkgs.legacyPackages.${system};
+        novaboot = (import ./novaboot.nix { inherit self pkgs; });
+      in {
+        # Utilized by `nix build .`
+        defaultPackage = novaboot.novaboot;
+
+        packages.novaboot = novaboot.novaboot;
+        packages.novaboot-server = novaboot.novaboot_server;
+
+        devShell = pkgs.mkShell {
+          inputsFrom = [
+            (import ./novaboot.nix {
+              inherit self pkgs;
+              otherPerlPackages = [ pkgs.perl.pkgs.PodParser ];
+            }).novaboot
+          ];
+          buildInputs = with pkgs; [
+            syslinux
+            cdrkit
+            grub2
+            dhcp
+          ];
+        };
+
+        # Default overlay, for use in dependent flakes
+        overlay = final: prev: { };
+
+        # Default module, for use in dependent flakes
+        #nixosModule = { config, ... }: { options = {}; config = {}; };
+
+        # Same idea as nixosModule but a list or attrset of them.
+        #nixosModules = { exampleModule = self.nixosModule; };
+      });
+}
diff --git a/novaboot.nix b/novaboot.nix
new file mode 100644 (file)
index 0000000..dca04a9
--- /dev/null
@@ -0,0 +1,37 @@
+{
+  self,
+  nixpkgs ? <nixpkgs>,
+  pkgs ? import nixpkgs {},
+  otherPerlPackages ? []
+}:
+with pkgs;
+let
+  IO-Stty = perlPackages.buildPerlPackage {
+    pname = "IO-Stty";
+    version = "0.04";
+    src = fetchurl {
+      url = "mirror://cpan/authors/id/T/TO/TODDR/IO-Stty-0.04.tar.gz";
+      sha256 = "1hjicqy50mgbippn310k4zclr9ksz05yyg81za3q4gb9m3qhk5aw";
+    };
+  };
+  perlEnv = (perl.withPackages (p: [ p.Expect IO-Stty ] ++ otherPerlPackages));
+in
+{
+  novaboot = stdenv.mkDerivation {
+    name = "novaboot";
+    src = self;
+    buildInputs = [ perlEnv rsync ];
+    installPhase = ''
+    make install DESTDIR=$out PREFIX=
+  '';
+  };
+  novaboot-server = stdenv.mkDerivation {
+    name = "novaboot-server";
+    src = self;
+    nativeBuildInputs = [ perl ];
+    buildInputs = [ rsync ];
+    installPhase = ''
+    make -C server install DESTDIR=$out PREFIX=
+  '';
+  };
+}
index 0cdacc477f564693ecac8d7138e716e59acfb1b4..db84e3d07dd404a49131d2096ea59ce8daa363c5 100644 (file)
--- a/shell.nix
+++ b/shell.nix
@@ -1,16 +1,3 @@
-{ pkgs ? import <nixpkgs> {} }:
-with pkgs;
-mkShell {
-  inputsFrom = [
-    (import ./default.nix {
-      inherit pkgs;
-      otherPerlPackages = [ perl.pkgs.PodParser ];
-    }).novaboot
-  ];
-  buildInputs = with pkgs; [
-    syslinux
-    cdrkit
-    grub2
-    dhcp
-  ];
-}
+(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
+  src = builtins.fetchGit ./.;
+}).shellNix