From 32b2b27509685655197b3d2b3cee80358d2cd905 Mon Sep 17 00:00:00 2001 From: Nico Jensch Date: Wed, 27 Sep 2023 08:37:45 +0200 Subject: [PATCH] feat: add flake.nix to allow building NixOS packages --- flake.lock | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 51 +++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2d1b886 --- /dev/null +++ b/flake.lock @@ -0,0 +1,94 @@ +{ + "nodes": { + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1694081375, + "narHash": "sha256-vzJXOUnmkMCm3xw8yfPP5m8kypQ3BhAIRe4RRCWpzy8=", + "owner": "nix-community", + "repo": "naersk", + "rev": "3f976d822b7b37fc6fb8e6f157c2dd05e7e94e89", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1695318763, + "narHash": "sha256-FHVPDRP2AfvsxAdc+AsgFJevMz5VBmnZglFUMlxBkcY=", + "path": "/nix/store/p7iz0r8gs6ppkhj83zjmwyd21k8b7v3y-source", + "rev": "e12483116b3b51a185a33a272bf351e357ba9a99", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1695318763, + "narHash": "sha256-FHVPDRP2AfvsxAdc+AsgFJevMz5VBmnZglFUMlxBkcY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e12483116b3b51a185a33a272bf351e357ba9a99", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "naersk": "naersk", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d7fb5f9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + # Websurfx NixOS flake + inputs = { + naersk.url = "github:nix-community/naersk/master"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + naersk, + nixpkgs, + self, + utils, + }: + # We do this for all systems - namely x86_64-linux, aarch64-linux, + # x86_64-darwin and aarch64-darwin + utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs {inherit system;}; + naersk-lib = pkgs.callPackage naersk {}; + in rec { + # Build via nix build .#defaultPackage.x86_64-linux + defaultPackage = naersk-lib.buildPackage { + # The build dependencies + buildInputs = with pkgs; [pkg-config openssl]; + src = ./.; + }; + + # Enter devshell with all the tools via "nix develop" + # or "nix-shell" + devShell = with pkgs; + mkShell { + buildInputs = [ + actionlint + cargo + haskellPackages.hadolint + nodePackages_latest.cspell + nodePackages_latest.eslint + nodePackages_latest.markdownlint-cli2 + nodePackages_latest.stylelint + nodePackages_latest.stylelint + rustPackages.clippy + rustc + yamllint + ]; + RUST_SRC_PATH = rustPlatform.rustLibSrc; + }; + + # Build via "nix build .#websurfx.x86_64-linux" + websurfx = defaultPackage; + }); +}