diff options
Diffstat (limited to 'nix')
| -rw-r--r-- | nix/derivation.nix | 7 | ||||
| -rw-r--r-- | nix/dev/checks.nix | 27 | ||||
| -rw-r--r-- | nix/dev/docker.nix | 25 | ||||
| -rw-r--r-- | nix/dev/flake.lock | 145 | ||||
| -rw-r--r-- | nix/dev/flake.nix | 62 | ||||
| -rw-r--r-- | nix/dev/procfile.nix | 13 | ||||
| -rw-r--r-- | nix/dev/shell.nix | 45 | ||||
| -rw-r--r-- | nix/dev/static.nix | 39 | ||||
| -rw-r--r-- | nix/dev/treefmt.nix | 21 | ||||
| -rw-r--r-- | nix/docker.nix | 43 |
10 files changed, 47 insertions, 380 deletions
diff --git a/nix/derivation.nix b/nix/derivation.nix index fa4867a..6a25976 100644 --- a/nix/derivation.nix +++ b/nix/derivation.nix @@ -3,7 +3,7 @@ stdenv, rustPlatform, darwin, - self, + self ? {inherit ((lib.importTOML ../Cargo.toml).package) version;}, lto ? true, optimizeSize ? false, }: @@ -11,7 +11,8 @@ rustPlatform.buildRustPackage { pname = "teawiebot"; version = (lib.importTOML ../Cargo.toml).package.version - + "-${self.shortRev or self.dirtyShortRev or "unknown-dirty"}"; + + "-" + + self.shortRev or self.dirtyShortRev or self.version or "unknown"; __structuredAttrs = true; @@ -43,7 +44,7 @@ rustPlatform.buildRustPackage { ); in { - GIT_SHA = self.shortRev or self.dirtyShortRev or "unknown-dirty"; + GIT_SHA = self.shortRev or self.dirtyShortRev or "unknown"; } // lib.optionalAttrs lto (toRustFlags { lto = "thin"; diff --git a/nix/dev/checks.nix b/nix/dev/checks.nix deleted file mode 100644 index 1d65625..0000000 --- a/nix/dev/checks.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - perSystem = { - lib, - pkgs, - ... - }: { - checks = { - actionlint = pkgs.runCommand "check-actionlint" {} '' - ${lib.getExe pkgs.actionlint} ${../../.github/workflows}/* - touch $out - ''; - - editorconfig = pkgs.runCommand "check-editorconfig" {} '' - cd ${../../.} - ${lib.getExe pkgs.editorconfig-checker} \ - -exclude '.git' . - - touch $out - ''; - - statix = pkgs.runCommand "check-statix" {} '' - ${lib.getExe pkgs.statix} check ${../../.} - touch $out - ''; - }; - }; -} diff --git a/nix/dev/docker.nix b/nix/dev/docker.nix deleted file mode 100644 index b209015..0000000 --- a/nix/dev/docker.nix +++ /dev/null @@ -1,25 +0,0 @@ -{withSystem, ...}: { - perSystem = { - lib, - pkgs, - self', - ... - }: let - containerFor = arch: - pkgs.dockerTools.buildLayeredImage { - name = "teawiebot"; - tag = "latest-${arch}"; - contents = [pkgs.dockerTools.caCertificates]; - config.Cmd = [ - (lib.getExe self'.packages."teawiebot-static-${arch}") - ]; - - architecture = withSystem "${arch}-linux" ({pkgs, ...}: pkgs.pkgsStatic.go.GOARCH); - }; - in { - packages = { - container-x86_64 = containerFor "x86_64"; - container-aarch64 = containerFor "aarch64"; - }; - }; -} diff --git a/nix/dev/flake.lock b/nix/dev/flake.lock deleted file mode 100644 index cb3fec6..0000000 --- a/nix/dev/flake.lock +++ /dev/null @@ -1,145 +0,0 @@ -{ - "nodes": { - "fenix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "rust-analyzer-src": "rust-analyzer-src" - }, - "locked": { - "lastModified": 1713421495, - "narHash": "sha256-5vVF9W1tJT+WdfpWAEG76KywktKDAW/71mVmNHEHjac=", - "owner": "nix-community", - "repo": "fenix", - "rev": "fd47b1f9404fae02a4f38bd9f4b12bad7833c96b", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "fenix", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1712014858, - "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "get-flake": { - "locked": { - "lastModified": 1694475786, - "narHash": "sha256-s5wDmPooMUNIAAsxxCMMh9g68AueGg63DYk2hVZJbc8=", - "owner": "ursi", - "repo": "get-flake", - "rev": "ac54750e3b95dab6ec0726d77f440efe6045bec1", - "type": "github" - }, - "original": { - "owner": "ursi", - "repo": "get-flake", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1713442664, - "narHash": "sha256-LoExypse3c/uun/39u4bPTN4wejIF7hNsdITZO41qTw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d764f230634fa4f86dc8d01c6af9619c7cc5d225", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "procfile-nix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1713576892, - "narHash": "sha256-458FHKn05FCX+fTOuHEobfJjADBKitzrd1SoPXSQOJc=", - "owner": "getchoo", - "repo": "procfile-nix", - "rev": "04cfa7931e996cb81c5848b559cb316c7f907b56", - "type": "github" - }, - "original": { - "owner": "getchoo", - "repo": "procfile-nix", - "type": "github" - } - }, - "root": { - "inputs": { - "fenix": "fenix", - "flake-parts": "flake-parts", - "get-flake": "get-flake", - "nixpkgs": "nixpkgs", - "procfile-nix": "procfile-nix", - "treefmt-nix": "treefmt-nix" - } - }, - "rust-analyzer-src": { - "flake": false, - "locked": { - "lastModified": 1713373173, - "narHash": "sha256-octd9BFY9G/Gbr4KfwK4itZp4Lx+qvJeRRcYnN+dEH8=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "46702ffc1a02a2ac153f1d1ce619ec917af8f3a6", - "type": "github" - }, - "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", - "type": "github" - } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1711963903, - "narHash": "sha256-N3QDhoaX+paWXHbEXZapqd1r95mdshxToGowtjtYkGI=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "49dc4a92b02b8e68798abd99184f228243b6e3ac", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/nix/dev/flake.nix b/nix/dev/flake.nix deleted file mode 100644 index 1442839..0000000 --- a/nix/dev/flake.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - - flake-parts = { - url = "github:hercules-ci/flake-parts"; - inputs.nixpkgs-lib.follows = "nixpkgs"; - }; - - fenix = { - url = "github:nix-community/fenix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - get-flake.url = "github:ursi/get-flake"; - - treefmt-nix = { - url = "github:numtide/treefmt-nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - procfile-nix = { - url = "github:getchoo/procfile-nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - - outputs = inputs: - inputs.flake-parts.lib.mkFlake {inherit inputs;} { - systems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - - imports = [ - # dev utils - ./checks.nix - ./procfile.nix - ./shell.nix - ./treefmt.nix - - # special, private builds - ./docker.nix - ./static.nix - - inputs.treefmt-nix.flakeModule - inputs.procfile-nix.flakeModule - ]; - - perSystem = { - lib, - system, - ... - }: { - _module.args = { - teawiebot' = lib.mapAttrs (lib.const (v: v.${system} or v)) (inputs.get-flake ../../.); - }; - }; - }; -} diff --git a/nix/dev/procfile.nix b/nix/dev/procfile.nix deleted file mode 100644 index 4b1c665..0000000 --- a/nix/dev/procfile.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - perSystem = { - lib, - pkgs, - ... - }: { - procfiles.daemons = { - processes = { - redis = lib.getExe' pkgs.redis "redis-server"; - }; - }; - }; -} diff --git a/nix/dev/shell.nix b/nix/dev/shell.nix deleted file mode 100644 index c5589ef..0000000 --- a/nix/dev/shell.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ - perSystem = { - config, - pkgs, - self', - teawiebot', - ... - }: { - devShells = { - default = pkgs.mkShell { - packages = [ - # rust tools - pkgs.clippy - pkgs.rustfmt - pkgs.rust-analyzer - - # nix tools - pkgs.deadnix - pkgs.nil - pkgs.statix - - # misc formatter/linters - pkgs.actionlint - self'.formatter - - config.procfiles.daemons.package - ]; - - inputsFrom = [teawiebot'.packages.teawiebot]; - RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; - }; - - ci = pkgs.mkShell { - packages = [ - pkgs.clippy - pkgs.rustfmt - - self'.formatter - ]; - - inputsFrom = [teawiebot'.packages.teawiebot]; - }; - }; - }; -} diff --git a/nix/dev/static.nix b/nix/dev/static.nix deleted file mode 100644 index e8780f4..0000000 --- a/nix/dev/static.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ - perSystem = { - lib, - pkgs, - inputs', - teawiebot', - ... - }: let - crossTargets = with pkgs.pkgsCross; { - x86_64 = musl64.pkgsStatic; - aarch64 = aarch64-multiplatform.pkgsStatic; - }; - - rustStdFor = pkgs: inputs'.fenix.packages.targets.${pkgs.stdenv.hostPlatform.rust.rustcTarget}.stable.rust-std; - toolchain = with inputs'.fenix.packages; - combine (lib.flatten [ - stable.cargo - stable.rustc - (map rustStdFor (lib.attrValues crossTargets)) - ]); - - rustPlatformFor = pkgs: - pkgs.makeRustPlatform ( - lib.genAttrs ["cargo" "rustc"] (lib.const toolchain) - ); - crossPlatforms = lib.mapAttrs (lib.const rustPlatformFor) crossTargets; - - buildTeawieWith = rustPlatform: - teawiebot'.packages.teawiebot.override { - inherit rustPlatform; - optimizeSize = true; - }; - in { - packages = { - teawiebot-static-x86_64 = buildTeawieWith crossPlatforms.x86_64; - teawiebot-static-aarch64 = buildTeawieWith crossPlatforms.aarch64; - }; - }; -} diff --git a/nix/dev/treefmt.nix b/nix/dev/treefmt.nix deleted file mode 100644 index 5e1fd1f..0000000 --- a/nix/dev/treefmt.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ - perSystem = { - treefmt = { - projectRootFile = "flake.nix"; - - programs = { - alejandra.enable = true; - deadnix.enable = true; - rustfmt.enable = true; - }; - - settings.global = { - excludes = [ - "./target" - "./flake.lock" - "./Cargo.lock" - ]; - }; - }; - }; -} diff --git a/nix/docker.nix b/nix/docker.nix new file mode 100644 index 0000000..79f49cc --- /dev/null +++ b/nix/docker.nix @@ -0,0 +1,43 @@ +{ + pkgs, + arch, + inputs, +}: let + inherit (pkgs) lib; + inputs' = lib.mapAttrs (_: lib.mapAttrs (_: v: v.${pkgs.system} or v)) inputs; + + crossTargets = with pkgs.pkgsCross; { + x86_64 = musl64.pkgsStatic; + aarch64 = aarch64-multiplatform.pkgsStatic; + }; + + rustStdFor = pkgs: inputs'.fenix.packages.targets.${pkgs.stdenv.hostPlatform.rust.rustcTarget}.stable.rust-std; + toolchain = with inputs'.fenix.packages; + combine (lib.flatten [ + stable.cargo + stable.rustc + (map rustStdFor (lib.attrValues crossTargets)) + ]); + + rustPlatformFor = pkgs: + pkgs.makeRustPlatform ( + lib.genAttrs ["cargo" "rustc"] (lib.const toolchain) + ); + crossPlatforms = lib.mapAttrs (lib.const rustPlatformFor) crossTargets; +in { + "teawiebot-static-${arch}" = inputs'.self.packages.teawiebot.override { + rustPlatform = crossPlatforms.${arch}; + optimizeSize = true; + }; + + "container-${arch}" = pkgs.dockerTools.buildLayeredImage { + name = "teawiebot"; + tag = "latest-${arch}"; + contents = [pkgs.dockerTools.caCertificates]; + config.Cmd = [ + (lib.getExe inputs'.self.packages."teawiebot-static-${arch}") + ]; + + architecture = inputs.nixpkgs.legacyPackages."${arch}-linux".pkgsStatic.go.GOARCH; + }; +} |
