Initial commit
This commit is contained in:
196
.github/workflows/rust.yml
vendored
Normal file
196
.github/workflows/rust.yml
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
name: Rust
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
{
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3",
|
||||
"name": "Checkout"
|
||||
},
|
||||
{
|
||||
"name": "Install Nix",
|
||||
"uses": "cachix/install-nix-action@v17",
|
||||
"with": { "extra-nix-config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" }
|
||||
},
|
||||
{
|
||||
"name": "cargo test",
|
||||
"run": "nix develop --command cargo test --verbose"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
build-release:
|
||||
{
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3",
|
||||
"name": "Checkout"
|
||||
},
|
||||
{
|
||||
"name": "Install Nix",
|
||||
"uses": "cachix/install-nix-action@v17",
|
||||
"with": { "extra-nix-config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" }
|
||||
},
|
||||
{
|
||||
"name": "cargo test (release)",
|
||||
"run": "nix develop --command cargo test --verbose --release"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
alejandra:
|
||||
{
|
||||
"name": "Nix formatting",
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3",
|
||||
"name": "Checkout"
|
||||
},
|
||||
{
|
||||
"name": "Install Nix",
|
||||
"uses": "cachix/install-nix-action@v17",
|
||||
"with": { "extra-nix-config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" }
|
||||
},
|
||||
{
|
||||
"name": "Run Alejandra",
|
||||
"run": "nix develop .#ci --command alejandra -- --check ."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
rust-fmt:
|
||||
{
|
||||
"name": "Rust formatting",
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3",
|
||||
"name": "Checkout"
|
||||
},
|
||||
{
|
||||
"name": "Install Nix",
|
||||
"uses": "cachix/install-nix-action@v17",
|
||||
"with": { "extra-nix-config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" }
|
||||
},
|
||||
{
|
||||
"name": "Run formatter",
|
||||
"run": "nix develop --command cargo -- fmt --all -- --check"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
clippy:
|
||||
{
|
||||
"name": "Clippy",
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3",
|
||||
"name": "Checkout"
|
||||
},
|
||||
{
|
||||
"name": "Install Nix",
|
||||
"uses": "cachix/install-nix-action@v17",
|
||||
"with": { "extra-nix-config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" }
|
||||
},
|
||||
{
|
||||
"name": "Run Clippy",
|
||||
"run": "nix develop --command cargo -- clippy -- -D warnings"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
nix-build:
|
||||
{
|
||||
"name": "Nix build",
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3",
|
||||
"name": "Checkout"
|
||||
},
|
||||
{
|
||||
"name": "Install Nix",
|
||||
"uses": "cachix/install-nix-action@v17",
|
||||
"with": { "extra-nix-config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" }
|
||||
},
|
||||
{
|
||||
"name": "Build app",
|
||||
"run": "nix build"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
nix-run:
|
||||
{
|
||||
"name": "Run app through Nix",
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3",
|
||||
"name": "Checkout"
|
||||
},
|
||||
{
|
||||
"name": "Install Nix",
|
||||
"uses": "cachix/install-nix-action@v17",
|
||||
"with": { "extra-nix-config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" }
|
||||
},
|
||||
{
|
||||
"name": "Run app",
|
||||
"run": "nix run"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
linkcheck:
|
||||
{
|
||||
"name": "Check links",
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3",
|
||||
"name": "Checkout"
|
||||
},
|
||||
{
|
||||
"name": "Install Nix",
|
||||
"uses": "cachix/install-nix-action@v17",
|
||||
"with": { "extra-nix-config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" }
|
||||
},
|
||||
{
|
||||
"name": "Run link checker",
|
||||
"run": "nix develop .#ci --command markdown-link-check README.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
all-required-checks-complete:
|
||||
{
|
||||
"needs":
|
||||
[
|
||||
'nix-build',
|
||||
'nix-run',
|
||||
'build',
|
||||
'build-release',
|
||||
'alejandra',
|
||||
'clippy',
|
||||
'rust-fmt',
|
||||
'linkcheck',
|
||||
],
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{ "run": "echo \"All required checks complete.\"" }
|
||||
]
|
||||
}
|
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
target/
|
||||
.idea/
|
||||
*.iml
|
||||
.vscode/
|
||||
.profile*
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "performance_aware_programming"
|
||||
version = "0.1.0"
|
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "performance_aware_programming"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
128
flake.lock
generated
Normal file
128
flake.lock
generated
Normal file
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"nodes": {
|
||||
"crate2nix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1678820090,
|
||||
"narHash": "sha256-4FFeonajXNqiSP0PqUlC1wmTyPC8SX6SthEvgRjMupw=",
|
||||
"owner": "kolloch",
|
||||
"repo": "crate2nix",
|
||||
"rev": "4fd826e37bec90dfe26ca16cb6e632c617cc7c0d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kolloch",
|
||||
"repo": "crate2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1679705136,
|
||||
"narHash": "sha256-MDlZUR7wJ3PlPtqwwoGQr3euNOe0vdSSteVVOef7tBY=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8f40f2f90b9c9032d1b824442cfbbe0dbabd0dbd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1679734080,
|
||||
"narHash": "sha256-z846xfGLlon6t9lqUzlNtBOmsgQLQIZvR6Lt2dImk1M=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dbf5322e93bcc6cfc52268367a8ad21c09d76fea",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crate2nix": "crate2nix",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1679106165,
|
||||
"narHash": "sha256-03Opt2yu4E/AIFjvlgib0/nhMn6B4B/t/nvwS2bzOGw=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "7313c06ac334d6262ddfe30a38b3abc3da6bd565",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1678901627,
|
||||
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
111
flake.nix
Normal file
111
flake.nix
Normal file
@@ -0,0 +1,111 @@
|
||||
{
|
||||
description = "Coursework for Performance-Aware Programming";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
crate2nix = {
|
||||
url = "github:kolloch/crate2nix";
|
||||
flake = false;
|
||||
};
|
||||
flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
utils,
|
||||
rust-overlay,
|
||||
crate2nix,
|
||||
...
|
||||
}: let
|
||||
name = "performance_aware_programming";
|
||||
in
|
||||
utils.lib.eachDefaultSystem
|
||||
(
|
||||
system: let
|
||||
# Imports
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
rust-overlay.overlays.default
|
||||
(self: super: {
|
||||
# Because rust-overlay bundles multiple rust packages into one
|
||||
# derivation, specify that mega-bundle here, so that crate2nix
|
||||
# will use them automatically.
|
||||
rustc = self.rust-bin.nightly.latest.default;
|
||||
cargo = self.rust-bin.nightly.latest.default;
|
||||
})
|
||||
];
|
||||
};
|
||||
inherit
|
||||
(import "${crate2nix}/tools.nix" {inherit pkgs;})
|
||||
generatedCargoNix
|
||||
;
|
||||
|
||||
# Create the cargo2nix project
|
||||
project =
|
||||
pkgs.callPackage
|
||||
(generatedCargoNix {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
})
|
||||
{
|
||||
# Individual crate overrides go here
|
||||
# Example: https://github.com/balsoft/simple-osd-daemons/blob/6f85144934c0c1382c7a4d3a2bbb80106776e270/flake.nix#L28-L50
|
||||
defaultCrateOverrides =
|
||||
pkgs.defaultCrateOverrides
|
||||
// {
|
||||
# The app crate itself is overriden here. Typically we
|
||||
# configure non-Rust dependencies (see below) here.
|
||||
${name} = oldAttrs:
|
||||
{
|
||||
inherit buildInputs nativeBuildInputs;
|
||||
}
|
||||
// buildEnvVars;
|
||||
};
|
||||
};
|
||||
|
||||
# Configuration for the non-Rust dependencies
|
||||
buildInputs = with pkgs; [openssl.dev];
|
||||
nativeBuildInputs = with pkgs; [rustc cargo pkgconfig];
|
||||
buildEnvVars = {
|
||||
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
||||
};
|
||||
in rec {
|
||||
packages.${name} = project.workspaceMembers.${name}.build;
|
||||
|
||||
# `nix build`
|
||||
defaultPackage = packages.${name};
|
||||
|
||||
# `nix run`
|
||||
apps.${name} = utils.lib.mkApp {
|
||||
inherit name;
|
||||
drv = packages.${name};
|
||||
};
|
||||
defaultApp = apps.${name};
|
||||
|
||||
# `nix develop`
|
||||
devShells = {
|
||||
ci =
|
||||
pkgs.mkShell {
|
||||
inherit nativeBuildInputs;
|
||||
buildInputs = [pkgs.nodePackages.markdown-link-check pkgs.alejandra] ++ buildInputs;
|
||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
}
|
||||
// buildEnvVars;
|
||||
default =
|
||||
pkgs.mkShell
|
||||
{
|
||||
inherit buildInputs nativeBuildInputs;
|
||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
}
|
||||
// buildEnvVars;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
3
src/main.rs
Normal file
3
src/main.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
Reference in New Issue
Block a user