From 6674db8b66ac65068865864e54cb92baf9fdde7b Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Mon, 2 Oct 2023 00:56:21 -0700 Subject: new rust template --- flake.nix | 5 +++ rust/.envrc | 1 + rust/.gitignore | 5 +++ rust/Cargo.lock | 7 ++++ rust/Cargo.toml | 6 +++ rust/flake.lock | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ rust/flake.nix | 37 ++++++++++++++++ rust/src/main.rs | 6 +++ 8 files changed, 192 insertions(+) create mode 100644 rust/.envrc create mode 100644 rust/.gitignore create mode 100644 rust/Cargo.lock create mode 100644 rust/Cargo.toml create mode 100644 rust/flake.lock create mode 100644 rust/flake.nix create mode 100644 rust/src/main.rs diff --git a/flake.nix b/flake.nix index 87e88e4..c0b31de 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,11 @@ path = ./base; description = "Uses direnv and not much else."; }; + + rust = { + path = ./rust; + description = "A Rust project built using Cargo and crane."; + }; }; defaultTemplate = self.templates.base; diff --git a/rust/.envrc b/rust/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/rust/.envrc @@ -0,0 +1 @@ +use flake diff --git a/rust/.gitignore b/rust/.gitignore new file mode 100644 index 0000000..3a6e63d --- /dev/null +++ b/rust/.gitignore @@ -0,0 +1,5 @@ +/result +/result-* +/target +/.direnv +*.swp diff --git a/rust/Cargo.lock b/rust/Cargo.lock new file mode 100644 index 0000000..c3aedd7 --- /dev/null +++ b/rust/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hello" +version = "0.1.0" diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..9618802 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "hello" +version = "0.1.0" +authors = ["Irene Knapp "] +edition = "2018" + diff --git a/rust/flake.lock b/rust/flake.lock new file mode 100644 index 0000000..816e79b --- /dev/null +++ b/rust/flake.lock @@ -0,0 +1,125 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1696205956, + "narHash": "sha256-bEzeEv/atc6lz2VZl78UiL0BEuVeNSa2HKKjpZAeQrM=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7fde5aa62269b01f04269f3007435759dc1b18a1", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "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": { + "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" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1696039360, + "narHash": "sha256-g7nIUV4uq1TOVeVIDEZLb005suTWCUjSY0zYOlSBsyE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "32dcb45f66c0487e92db8303a798ebc548cadedc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "nixpkgs": "nixpkgs" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "crane", + "flake-utils" + ], + "nixpkgs": [ + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1695003086, + "narHash": "sha256-d1/ZKuBRpxifmUf7FaedCqhy0lyVbqj44Oc2s+P5bdA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "b87a14abea512d956f0b89d0d8a1e9b41f3e20ff", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "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/rust/flake.nix b/rust/flake.nix new file mode 100644 index 0000000..a01f74d --- /dev/null +++ b/rust/flake.nix @@ -0,0 +1,37 @@ +{ + inputs = { + nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixos-23.05"; + }; + + crane = { + inputs.nixpkgs.follows = "nixpkgs"; + url = "github:ipetkov/crane"; + }; + }; + + outputs = { self, nixpkgs, crane }: + let supportedSystems = [ "aarch64-linux" "x86_64-linux" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in { + packages = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in { + default = crane.lib.${system}.buildPackage { + src = ./.; + }; + }); + + devShells = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + cargo + rustc + ]; + }; + }); + }; +} + diff --git a/rust/src/main.rs b/rust/src/main.rs new file mode 100644 index 0000000..c7328a8 --- /dev/null +++ b/rust/src/main.rs @@ -0,0 +1,6 @@ +#![forbid(unsafe_code)] + +fn main() { + println!("Hello!"); +} + -- cgit 1.4.1