From: Michal Sojka Date: Sun, 3 Apr 2022 12:22:39 +0000 (+0200) Subject: nix: Convert to flakes X-Git-Tag: 20220425~7 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/novaboot.git/commitdiff_plain/341d7ec4efdc334e1b938d6c722c21192e601ce0 nix: Convert to flakes We use flake-comapt to keep compatibility the old Nix. --- diff --git a/default.nix b/default.nix index d1e317a..b22e926 100644 --- a/default.nix +++ b/default.nix @@ -1,36 +1,3 @@ -{ - 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 index 0000000..5fe8f21 --- /dev/null +++ b/flake.lock @@ -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 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 index 0000000..dca04a9 --- /dev/null +++ b/novaboot.nix @@ -0,0 +1,37 @@ +{ + self, + 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= + ''; + }; +} diff --git a/shell.nix b/shell.nix index 0cdacc4..db84e3d 100644 --- a/shell.nix +++ b/shell.nix @@ -1,16 +1,3 @@ -{ pkgs ? import {} }: -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