| 19 Oct 2022 |
aktaboot | * there's fenix, naersk and oxalica for building with rust ? | 18:29:24 |
aktaboot | * there's fenix, naersk and oxalica for building rust ? | 18:29:33 |
aktaboot | will check naersk ig | 18:29:46 |
Charles ⚡️ | i don't like overlays so i don't use oxalica | 18:29:52 |
Charles ⚡️ | steal this:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
, nixpkgs
, flake-utils
, fenix
}: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
rust = fenix.packages.${system};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
in
{
packages.default = (pkgs.makeRustPlatform {
inherit (rust.stable) cargo rustc;
}).buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;
cargoLock.lockFile = ./Cargo.lock;
src = builtins.filterSource
# Exclude `target` because it's huge
(path: type: !(type == "directory" && baseNameOf path == "target"))
./.;
# This is disabled so CI can be impure and not break Nix builds
doCheck = false;
};
devShells.default = self.packages.${system}.default.overrideAttrs (old: {
# Rust Analyzer needs to be able to find the path to default crate
# sources, and it can read this environment variable to do so
RUST_SRC_PATH = "${rust.stable.rust-src}/lib/rustlib/src/rust/library";
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ (with pkgs; [
file
ncurses
nixpkgs-fmt
shellcheck
shfmt
]) ++ (with rust; [
latest.rustfmt
stable.clippy
stable.rust-src
]) ++ (with pkgs.nodePackages; [
markdownlint-cli
]);
});
checks = {
packagesDefault = self.packages.${system}.default;
devShellsDefault = self.devShells.${system}.default;
};
});
}
| 18:30:24 |
Charles ⚡️ | wait no | 18:30:37 |
Charles ⚡️ | * steal this:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
, nixpkgs
, flake-utils
, fenix
, naersk
}: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
toolchain = fenix.packages.${system}.stable;
in
{
packages.default = (pkgs.callPackage naersk {
inherit (toolchain) rustc cargo;
}).buildPackage {
src = ./.;
};
devShells.default = pkgs.mkShell {
# Rust Analyzer needs to be able to find the path to default crate
# sources, and it can read this environment variable to do so
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
# Development tools
nativeBuildInputs = (with toolchain; [
cargo
clippy
rust-src
rustc
# Always use nightly rustfmt because most of its options are unstable
fenix.packages.${system}.latest.rustfmt
]) ++ (with pkgs; [
file
ncurses
nixpkgs-fmt
shellcheck
shfmt
]) ++ (with pkgs.nodePackages; [
markdownlint-cli
]);
};
checks = {
packagesDefault = self.packages.${system}.default;
devShellsDefault = self.devShells.${system}.default;
};
});
}
| 18:31:08 |
Charles ⚡️ | okay now steal it | 18:31:12 |
Charles ⚡️ | you'll just need to add your repo as an input, change line 33, and get rid of the devshell stuff | 18:32:09 |
Charles ⚡️ | then it should work | 18:32:12 |
Charles ⚡️ | except for the graphics stuff | 18:32:15 |
Charles ⚡️ | you'll need to add other things for that | 18:32:19 |
aktaboot | okay will try thanks | 18:35:26 |
Charles ⚡️ | for graphics, maybe something like this will be a good start: https://or.computer.surgery/charles/maxels/-/blob/main/flake.nix#L38-55 | 18:35:50 |
aktaboot | what do you mean by graphics ? | 18:36:58 |
Charles ⚡️ | well, it looks like the thing you're building depends on winit and such | 18:37:20 |
Charles ⚡️ | so it's probably a graphical application | 18:37:35 |
aktaboot | it is | 18:37:42 |
Charles ⚡️ | and so you need to give it x11 libs so it can do graphics | 18:37:52 |
Charles ⚡️ | and vulkan or whatever so it can bother the gpu to do stuff | 18:38:02 |
aktaboot | I'm on wayland but Ig it doesn't matter | 18:38:18 |
Charles ⚡️ | then you'll probably need to add wayland things | 18:38:31 |
aktaboot | oh | 18:38:41 |
Charles ⚡️ | unfortunately i have an nvidia gpu so i'm not allowed to run wayland and thus i won't be of much help there | 18:39:29 |
aktaboot | no problemo, I'll figure it out :D | 18:40:03 |
Charles ⚡️ | the linker errors should be pretty clear on what libraries you need | 18:40:17 |
aktaboot | does the flake have to be named flake.nix ? | 18:42:58 |
Charles ⚡️ | i believe so | 18:43:07 |
benjamin ⚡️ | In reply to @charles:computer.surgery unfortunately i have an nvidia gpu so i'm not allowed to run wayland and thus i won't be of much help there don't the proprietary drivers support dmabuf now? | 19:04:57 |
Charles ⚡️ | all i know is i still get sassy error messages from sway | 19:05:20 |