diff --git a/.envrc b/.envrc index 1d953f4..3550a30 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use nix +use flake diff --git a/default.nix b/default.nix deleted file mode 100644 index 392aee9..0000000 --- a/default.nix +++ /dev/null @@ -1,63 +0,0 @@ -let - inputs = import ./deps; - system = "x86_64-linux"; - pkgs = import inputs.nixpkgs { inherit system; }; - - pre-commit-hook = (import inputs."git-hooks.nix").run { - src = ./.; - - hooks = { - statix.enable = true; - deadnix.enable = true; - rfc101 = { - enable = true; - name = "RFC-101 formatting"; - entry = "${pkgs.lib.getExe pkgs.nixfmt-rfc-style}"; - files = "\\.nix$"; - }; - commitizen.enable = true; - }; - }; -in - -rec { - devShells.default = pkgs.mkShell { - nativeBuildInputs = [ pkgs.bashInteractive ]; - buildInputs = with pkgs; [ - quarto - texliveFull - jose - clevis - jq - ]; - shellHook = '' - ${pre-commit-hook.shellHook} - ''; - }; - - packages.x86_64-linux = { - website = pkgs.callPackage ( - { stdenv, quarto, ... }: - - stdenv.mkDerivation { - name = "fosdem24-clevis"; - src = ./.; - - buildInputs = [ quarto ]; - - buildPhase = '' - mkdir _slides - HOME=. quarto render index.qmd --to revealjs --output-dir _slides - ''; - - installPhase = '' - cp -r _slides $out - ''; - } - ) { }; - }; - - checks.default = { - inherit packages; - }; -} diff --git a/deps/default.nix b/deps/default.nix deleted file mode 100644 index 8d8f2bf..0000000 --- a/deps/default.nix +++ /dev/null @@ -1,79 +0,0 @@ -# Generated by npins. Do not modify; will be overwritten regularly -let - data = builtins.fromJSON (builtins.readFile ./sources.json); - inherit (data) version; - - mkSource = - spec: - assert spec ? type; - let - path = - if spec.type == "Git" then - mkGitSource spec - else if spec.type == "GitRelease" then - mkGitSource spec - else if spec.type == "PyPi" then - mkPyPiSource spec - else if spec.type == "Channel" then - mkChannelSource spec - else - builtins.throw "Unknown source type ${spec.type}"; - in - spec // { outPath = path; }; - - mkGitSource = - { - repository, - revision, - url ? null, - hash, - ... - }: - assert repository ? type; - # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository - # In the latter case, there we will always be an url to the tarball - if url != null then - (builtins.fetchTarball { - inherit url; - sha256 = hash; # FIXME: check nix version & use SRI hashes - }) - else - assert repository.type == "Git"; - let - urlToName = - url: rev: - let - matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url; - - short = builtins.substring 0 7 rev; - - appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; - in - "${if matched == null then "source" else builtins.head matched}${appendShort}"; - name = urlToName repository.url revision; - in - builtins.fetchGit { - inherit (repository) url; - rev = revision; - inherit name; - # hash = hash; - }; - - mkPyPiSource = - { url, hash, ... }: - builtins.fetchurl { - inherit url; - sha256 = hash; - }; - - mkChannelSource = - { url, hash, ... }: - builtins.fetchTarball { - inherit url; - sha256 = hash; - }; -in -if version == 3 then - builtins.mapAttrs (_: mkSource) data.pins -else - throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" diff --git a/deps/sources.json b/deps/sources.json deleted file mode 100644 index bd2194d..0000000 --- a/deps/sources.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "pins": { - "git-hooks.nix": { - "type": "Git", - "repository": { - "type": "GitHub", - "owner": "cachix", - "repo": "git-hooks.nix" - }, - "branch": "master", - "revision": "f451c19376071a90d8c58ab1a953c6e9840527fd", - "url": "https://github.com/cachix/git-hooks.nix/archive/f451c19376071a90d8c58ab1a953c6e9840527fd.tar.gz", - "hash": "1gdkg3bcxqzccb7gzp2gvbwjk7lnv3p9sl10113z9dnmn6bx8lz8" - }, - "nixpkgs": { - "type": "Channel", - "name": "nixpkgs-unstable", - "url": "https://releases.nixos.org/nixpkgs/nixpkgs-24.11pre658316.e36e9f57337d/nixexprs.tar.xz", - "hash": "0z1dl3aaxhia642i9xfv571r040axkbm1zyxylgmhsqkra5lxk8z" - } - }, - "version": 3 -} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2c642b2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1743931715, + "narHash": "sha256-bEWnr2OeYC5KDmYUR7QP+I/T8bnYt/Rc5iwfXUGP/Uo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b49ceb963bf623f1d779b782dbf3289ddb313c47", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} + diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ccf04d0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +{ + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + }; + + outputs = + { nixpkgs, ... }: + let + pkgs = import nixpkgs { system = "x86_64-linux"; }; + in + rec { + devShells.default = pkgs.mkShell { + nativeBuildInputs = [ pkgs.bashInteractive ]; + buildInputs = with pkgs; [ + quarto + texliveFull + ]; + }; + + packages.x86_64-linux = { + default = pkgs.callPackage ( + { + stdenv, + quarto, + which, + ... + }: + + stdenv.mkDerivation { + name = "coap-february-2025"; + src = ./.; + + buildInputs = [ + quarto + which + ]; + + buildPhase = '' + mkdir _slides + HOME=. quarto render index.qmd --output-dir _slides + ''; + + installPhase = '' + cp -r _slides $out + rm $out/index.qmd + rm $out/*.nix + ''; + } + ) { }; + }; + + checks.default = { + inherit packages; + }; + }; +}