-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
295 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Nix | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Nix | ||
uses: DeterminateSystems/nix-installer-action@v6 | ||
- name: Setup Nix cache | ||
uses: DeterminateSystems/magic-nix-cache-action@v2 | ||
|
||
- name: Build | ||
run: nix build -L --accept-flake-config --fallback .#valfisk | ||
|
||
check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Nix | ||
uses: DeterminateSystems/nix-installer-action@v6 | ||
- name: Setup Nix cache | ||
uses: DeterminateSystems/magic-nix-cache-action@v2 | ||
|
||
- name: Run checks | ||
run: nix flake check -L --accept-flake-config --show-trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Update flake.lock | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Install Nix | ||
uses: DeterminateSystems/nix-installer-action@v6 | ||
|
||
- name: Update lockfile | ||
uses: DeterminateSystems/update-flake-lock@v20 | ||
with: | ||
commit-msg: "chore(flake): update inputs" | ||
pr-title: "chore(flake): update inputs" | ||
token: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,8 @@ | |
.env | ||
.env.* | ||
!.env.example | ||
|
||
# nix stuff | ||
.direnv | ||
result* | ||
repl-result-out* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
naersk, | ||
stdenv, | ||
darwin, | ||
lib, | ||
}: | ||
naersk.buildPackage { | ||
src = lib.cleanSource ./.; | ||
|
||
nativeBuildInputs = lib.optionals stdenv.isDarwin [ | ||
darwin.apple_sdk_11_0.frameworks.CoreFoundation | ||
darwin.apple_sdk_11_0.frameworks.Security | ||
darwin.apple_sdk_11_0.frameworks.SystemConfiguration | ||
darwin.IOKit | ||
]; | ||
|
||
meta = with lib; { | ||
mainProgram = "valfisk"; | ||
description = "Next generation Ryanland Discord bot, written in Rust"; | ||
homepage = "https://github.com/ryanccn/valfisk"; | ||
maintainers = with maintainers; [getchoo ryanccn]; | ||
licenses = licenses.agpl3Only; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
lib, | ||
dockerTools, | ||
valfisk, | ||
}: | ||
dockerTools.buildImage { | ||
name = "valfisk"; | ||
tag = "latest"; | ||
|
||
copyToRoot = [ | ||
dockerTools.caCertificates | ||
]; | ||
|
||
config.Cmd = [ | ||
"${lib.getExe valfisk}" | ||
]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
description = "Next generation Ryanland Discord bot, written in Rust"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
naersk.url = "github:nix-community/naersk"; | ||
naersk.inputs.nixpkgs.follows = "nixpkgs"; | ||
fenix.url = "github:nix-community/fenix"; | ||
fenix.inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
outputs = { | ||
self, | ||
nixpkgs, | ||
naersk, | ||
fenix, | ||
... | ||
}: let | ||
inherit (nixpkgs) lib; | ||
|
||
systems = [ | ||
"x86_64-linux" | ||
"aarch64-linux" | ||
"x86_64-darwin" | ||
"aarch64-darwin" | ||
]; | ||
|
||
forAllSystems = fn: lib.genAttrs systems (sys: fn nixpkgs.legacyPackages.${sys}); | ||
fromOverlay = p: lib.fix (final: self.overlays.default final p); | ||
in { | ||
devShells = forAllSystems (pkgs: { | ||
default = pkgs.mkShell { | ||
packages = with pkgs; [ | ||
rustfmt | ||
]; | ||
|
||
inputsFrom = [self.packages.${pkgs.system}.default]; | ||
}; | ||
}); | ||
|
||
formatter = forAllSystems (pkgs: pkgs.alejandra); | ||
|
||
# mainly for internal use. cross compiles from darwin -> linux | ||
cross = forAllSystems ( | ||
pkgs: let | ||
crossPkgsFor = { | ||
x86_64-linux = pkgs.pkgsCross.gnu64; | ||
aarch64-linux = pkgs.pkgsCross.aarch64-multiplatform; | ||
}; | ||
|
||
toCrossPkgs' = sys: let | ||
crossPkgs = crossPkgsFor.${sys}; | ||
toolchain = with fenix.packages.${pkgs.system}; | ||
combine [ | ||
minimal.rustc | ||
minimal.cargo | ||
targets.${crossPkgs.stdenv.hostPlatform.config}.minimal.rust-std | ||
]; | ||
|
||
naersk' = naersk.lib.${pkgs.system}.override { | ||
cargo = toolchain; | ||
rustc = toolchain; | ||
}; | ||
|
||
pkgs' = fromOverlay crossPkgs; | ||
in rec { | ||
valfisk = pkgs'.valfisk.override {naersk = naersk';}; | ||
valfisk-docker = pkgs'.valfisk-docker.override {inherit valfisk;}; | ||
}; | ||
in | ||
lib.optionalAttrs pkgs.stdenv.isDarwin ( | ||
lib.genAttrs (builtins.attrNames crossPkgsFor) toCrossPkgs' | ||
) | ||
); | ||
|
||
packages = forAllSystems (pkgs: let | ||
pkgs' = fromOverlay pkgs; | ||
in { | ||
inherit (pkgs') valfisk valfisk-docker; | ||
default = pkgs'.valfisk; | ||
}); | ||
|
||
overlays.default = final: prev: { | ||
valfisk = prev.callPackage ./default.nix { | ||
naersk = final.naersk or naersk.lib.${prev.stdenv.hostPlatform.system}; | ||
}; | ||
|
||
valfisk-docker = prev.callPackage ./docker.nix { | ||
inherit (final) valfisk; | ||
}; | ||
}; | ||
}; | ||
} |