diff options
| author | Fuwn <[email protected]> | 2024-09-30 02:34:59 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-09-30 02:34:59 +0000 |
| commit | d8dbcc4ed9dccb3c08fa0c15b10bdc9625c3c181 (patch) | |
| tree | f190033d181b27639ed49b66c8088d58477425cb | |
| parent | build(docker): add simple build.ninja for Dockerfile (diff) | |
| download | maple-d8dbcc4ed9dccb3c08fa0c15b10bdc9625c3c181.tar.xz maple-d8dbcc4ed9dccb3c08fa0c15b10bdc9625c3c181.zip | |
chore(nix): set up flake
| -rw-r--r-- | .envrc | 9 | ||||
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | flake.lock | 80 | ||||
| -rw-r--r-- | flake.nix | 89 | ||||
| -rw-r--r-- | shell.nix | 10 |
5 files changed, 190 insertions, 0 deletions
@@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +if type -P lorri &>/dev/null; then + eval "$(lorri direnv)" +else + echo 'while direnv evaluated .envrc, could not find the command "lorri" [https://github.com/nix-community/lorri]' + + use flake +fi @@ -14,3 +14,5 @@ build # Ninja .ninja_log +# Nix +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..55d28d1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,80 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": [ + "systems" + ] + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1727653192, + "narHash": "sha256-YBIXvJOLKU1FIQM0fB5lBLT1CoPpMCn03vHyNsVFXZ4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c6f2346239c6f6abdc8befcb2a10759083c85f5d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7abbcb5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,89 @@ +{ + description = "A very simple static Gemini server, now with Titan support!"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + systems.url = "github:nix-systems/default"; + + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.systems.follows = "systems"; + }; + }; + + outputs = + { + nixpkgs, + flake-utils, + self, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + + meta = with pkgs.lib; { + description = "A very simple static Gemini server, now with Titan support!"; + homepage = "https://github.com/gemrest/maple"; + license = licenses.gpl3Only; + maintainers = [ maintainers.Fuwn ]; + mainPackage = "maple"; + platforms = platforms.linux; + }; + + maple = (pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv).mkDerivation { + inherit meta; + + name = "maple"; + version = "0.1.6"; + src = pkgs.lib.cleanSource ./.; + + nativeBuildInputs = with pkgs; [ + ninja + clang + ]; + + buildInputs = [ + pkgs.libressl.dev + ]; + + buildPhase = '' + mkdir -p $out/bin + ninja + ''; + + installPhase = '' + cp build/maple $out/bin/maple + ''; + }; + in + { + packages = { + inherit maple; + + default = maple; + }; + + apps = { + maple = { + inherit meta; + + type = "app"; + program = "${maple}/bin/maple"; + }; + + default = self.apps.${system}.maple; + }; + + devShells.default = import ./shell.nix { + inherit pkgs; + }; + } + ); +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..55c7650 --- /dev/null +++ b/shell.nix @@ -0,0 +1,10 @@ +{ + pkgs ? import <nixpkgs> { }, +}: +pkgs.mkShell { + buildInputs = with pkgs; [ + libressl + ninja + clang + ]; +} |