summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix66
-rw-r--r--flake.nix44
-rw-r--r--nix/package.nix53
-rw-r--r--shell.nix17
4 files changed, 79 insertions, 101 deletions
diff --git a/default.nix b/default.nix
deleted file mode 100644
index be25d44..0000000
--- a/default.nix
+++ /dev/null
@@ -1,66 +0,0 @@
-{
- pkgs ? import nixpkgs {
- inherit system;
- config = { };
- overlays = [ ];
- },
- nixpkgs ? <nixpkgs>,
- system ? builtins.currentSystem,
-}:
-{
- website = pkgs.callPackage (
- {
- lib,
- stdenvNoCC,
- writeShellApplication,
- zola,
- }:
- stdenvNoCC.mkDerivation {
- name = "getchoo-website";
-
- src = lib.fileset.toSource {
- root = ./.;
- fileset = lib.fileset.unions [
- ./config.toml
- ./content
- ./static
- ./templates
- ];
- };
-
- nativeBuildInputs = [ zola ];
-
- dontConfigure = true;
- doCheck = false;
-
- buildPhase = ''
- runHook preBuild
- zola build
- runHook postBuild
- '';
-
- installPhase = ''
- runHook preInstall
- mv public $out
- runHook postInstall
- '';
-
- passthru = {
- serve = writeShellApplication {
- name = "serve";
- runtimeInputs = [ zola ];
-
- text = ''
- zola serve
- '';
- };
- };
-
- meta = {
- homepage = "https://github.com/getchoo/website";
- license = lib.licenses.mit;
- maintainers = with lib.maintainers; [ getchoo ];
- };
- }
- ) { };
-}
diff --git a/flake.nix b/flake.nix
index 0b705d1..530ade2 100644
--- a/flake.nix
+++ b/flake.nix
@@ -4,6 +4,8 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ nix-filter.url = "github:numtide/nix-filter";
+
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
@@ -14,45 +16,51 @@
{
self,
nixpkgs,
+ nix-filter,
treefmt-nix,
}:
let
inherit (nixpkgs) lib;
- systems = [
- "x86_64-linux"
- "aarch64-linux"
- "x86_64-darwin"
- "aarch64-darwin"
- ];
+ systems = lib.systems.flakeExposed;
forAllSystems = lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
- treefmtFor = forAllSystems (system: treefmt-nix.lib.evalModule nixpkgsFor.${system} ./treefmt.nix);
+ treefmtFor = forAllSystems (
+ system: treefmt-nix.lib.evalModule nixpkgsFor.${system} (self + "/treefmt.nix")
+ );
in
{
checks = forAllSystems (system: {
treefmt = treefmtFor.${system}.config.build.check self;
});
- devShells = forAllSystems (system: {
- default = import ./shell.nix {
- inherit system;
+ devShells = forAllSystems (
+ system:
+ let
pkgs = nixpkgsFor.${system};
- formatter = self.formatter.${system};
- };
- });
+ in
+ {
+ default = pkgs.mkShellNoCC {
+ packages = [
+ pkgs.zola
+ self.formatter.${system}
+ pkgs.actionlint
+ ];
+ };
+ }
+ );
formatter = forAllSystems (system: treefmtFor.${system}.config.build.wrapper);
packages = forAllSystems (
system:
let
- pkgs' = import ./. {
- inherit system;
- pkgs = nixpkgsFor.${system};
- };
+ pkgs = nixpkgsFor.${system};
in
- pkgs' // { default = pkgs'.website; }
+ {
+ website = pkgs.callPackage ./nix/package.nix { inherit nix-filter self; };
+ default = self.packages.${system}.website;
+ }
);
};
}
diff --git a/nix/package.nix b/nix/package.nix
new file mode 100644
index 0000000..63f4290
--- /dev/null
+++ b/nix/package.nix
@@ -0,0 +1,53 @@
+{
+ lib,
+ stdenvNoCC,
+ writeShellApplication,
+ miniserve,
+ zola,
+
+ nix-filter,
+ self,
+}:
+
+let
+ website = stdenvNoCC.mkDerivation {
+ pname = "getchoo-website";
+ version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
+
+ src = nix-filter.lib {
+ root = self;
+ include = [
+ "config.toml"
+ "content"
+ "static"
+ "templates"
+ ];
+ };
+
+ nativeBuildInputs = [ zola ];
+
+ dontConfigure = true;
+ dontFixup = true;
+
+ buildPhase = "zola build";
+ installPhase = "mv public $out";
+
+ passthru = {
+ serve = writeShellApplication {
+ name = "serve";
+ runtimeInputs = [ miniserve ];
+
+ text = ''
+ miniserve ${website}/
+ '';
+ };
+ };
+
+ meta = {
+ homepage = "https://github.com/getchoo/website";
+ license = lib.licenses.mit;
+ maintainers = with lib.maintainers; [ getchoo ];
+ };
+ };
+in
+website
diff --git a/shell.nix b/shell.nix
deleted file mode 100644
index 9daab94..0000000
--- a/shell.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- pkgs ? import nixpkgs {
- inherit system;
- config = { };
- overlays = [ ];
- },
- nixpkgs ? <nixpkgs>,
- system ? builtins.currentSystem,
- formatter ? pkgs.nixfmt-rfc-style,
-}:
-pkgs.mkShellNoCC {
- packages = [
- pkgs.zola
- formatter
- pkgs.actionlint
- ];
-}