Init repository with compileOptimized and vscode-extensions
This commit is contained in:
commit
7cd9555839
9 changed files with 224 additions and 0 deletions
27
flake.lock
Normal file
27
flake.lock
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1720957393,
|
||||
"narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "693bc46d169f5af9c992095736e82c3488bf7dbb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
20
flake.nix
Normal file
20
flake.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
description = "Collection of packages and overlays used by me";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
in
|
||||
{
|
||||
packages.${system} = pkgs.callPackage ./stackpkgs.nix {};
|
||||
overlays.default = import ./overlay.nix;
|
||||
};
|
||||
}
|
10
overlay.nix
Normal file
10
overlay.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
final: prev:
|
||||
|
||||
let
|
||||
stackpkgs = final.callPackage ./stackpkgs.nix;
|
||||
in
|
||||
builtins.removeAttrs stackpkgs [
|
||||
"vscode-extensions"
|
||||
] // {
|
||||
vscode-extensions = prev.vscode-extensions // stackpkgs.vscode-extensions;
|
||||
}
|
12
packages/compileOptimized.nix
Normal file
12
packages/compileOptimized.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{ lib, callPackage }:
|
||||
|
||||
let
|
||||
mkOverridablePackage = pkg: lib.makeOverridable (callPackage pkg {}) {};
|
||||
in
|
||||
{
|
||||
compileOptimized = rec {
|
||||
C = mkOverridablePackage ./compileOptimized/C.nix;
|
||||
CNoLTO = C.override { enableLTO = false; };
|
||||
Rust = mkOverridablePackage ./compileOptimized/Rust.nix;
|
||||
};
|
||||
}
|
24
packages/compileOptimized/C.nix
Normal file
24
packages/compileOptimized/C.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ lib }:
|
||||
|
||||
{
|
||||
optimizationLevel ? "O3",
|
||||
enableLTO ? true,
|
||||
enableNativeOptimizations ? true,
|
||||
additionalFlags ? []
|
||||
}:
|
||||
|
||||
pkg:
|
||||
|
||||
assert builtins.elem optimizationLevel [ "O0" "O1" "O2" "O3" "Ofast" "Os" "Oz" "Og" ];
|
||||
|
||||
let
|
||||
flags = [ "-${optimizationLevel}" ]
|
||||
++ lib.optional enableLTO "-flto"
|
||||
++ lib.optional enableNativeOptimizations "-march=native"
|
||||
++ additionalFlags;
|
||||
in
|
||||
|
||||
pkg.overrideAttrs (prevAttrs: {
|
||||
env.NIX_CFLAGS_COMPILE = (prevAttrs.env.NIX_CFLAGS_COMPILE or "")
|
||||
+ lib.strings.concatStringsSep " " flags;
|
||||
})
|
60
packages/compileOptimized/Rust.nix
Normal file
60
packages/compileOptimized/Rust.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{ lib }:
|
||||
|
||||
# See https://doc.rust-lang.org/cargo/reference/profiles.html
|
||||
# and https://doc.rust-lang.org/rustc/codegen-options/index.html
|
||||
# for list of options
|
||||
|
||||
{
|
||||
opt-level ? "3",
|
||||
debug ? "none",
|
||||
split-debuginfo ? "off",
|
||||
strip ? "symbols",
|
||||
debug-assertions ? false,
|
||||
overflow-checks ? false,
|
||||
lto ? "fat",
|
||||
panic ? "abort",
|
||||
codegen-units ? 1,
|
||||
enableNativeOptimizations ? true,
|
||||
enableNoPIC ? false,
|
||||
additionalFlags ? []
|
||||
}:
|
||||
|
||||
pkg:
|
||||
|
||||
assert builtins.elem opt-level [ "0" "1" "2" "3" "s" "z" ];
|
||||
assert builtins.elem debug [ "none" "line-directives-only" "line-tables-only" "limited" "full" ];
|
||||
assert builtins.elem split-debuginfo [ "off" "packed" "unpacked" ];
|
||||
assert builtins.elem strip [ "none" "debuginfo" "symbols" ];
|
||||
assert builtins.elem lto [ "off" "thin" "fat" ];
|
||||
assert builtins.elem panic [ "unwind" "abort" ];
|
||||
assert codegen-units > 0;
|
||||
|
||||
let
|
||||
codegenOptions = [
|
||||
"opt-level=${opt-level}"
|
||||
"debuginfo=${debug}"
|
||||
"split-debuginfo=${split-debuginfo}"
|
||||
"strip=${strip}"
|
||||
"debug-assertions=${lib.boolToString debug-assertions}"
|
||||
"overflow-checks=${lib.boolToString overflow-checks}"
|
||||
"lto=${lto}"
|
||||
"panic=${panic}"
|
||||
"codegen-units=${toString codegen-units}"
|
||||
]
|
||||
++ lib.optional (lto != "off") "embed-bitcode=true" # LLVM bitcode is required for performing LTO
|
||||
++ lib.optional enableNoPIC "relocation-model=static"
|
||||
++ lib.optional enableNativeOptimizations "target-cpu=native";
|
||||
in
|
||||
|
||||
pkg.overrideAttrs (finalAttrs: prevAttrs: {
|
||||
cargoBuildType = "release";
|
||||
|
||||
# Disable tests with abort panic strategy. Tests can only run with unwind strategy
|
||||
# See unstable panic-abort-tests option
|
||||
doCheck = prevAttrs.doCheck && panic != "abort";
|
||||
|
||||
RUSTFLAGS = (prevAttrs.RUSTFLAGS or "")
|
||||
+ lib.strings.concatMapStringsSep " " (flag: "-C ${flag}") codegenOptions
|
||||
+ " "
|
||||
+ lib.strings.concatStringsSep " " additionalFlags;
|
||||
})
|
27
packages/vscode-extensions.nix
Normal file
27
packages/vscode-extensions.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ lib, vscode-utils }:
|
||||
|
||||
let
|
||||
extensions = builtins.fromTOML (builtins.readFile ./vscode-extensions/extensions.toml);
|
||||
marketplaceBaseURL = "https://marketplace.visualstudio.com/items?itemName=";
|
||||
|
||||
buildExtension = (publisher: name: ext:
|
||||
vscode-utils.buildVscodeMarketplaceExtension {
|
||||
# Generate publisher and name
|
||||
# Replace hash with fake one if needed
|
||||
mktplcRef = ext.info
|
||||
// { inherit publisher name; }
|
||||
// lib.optionalAttrs (ext.info.hash == "fake") { hash = lib.fakeHash; };
|
||||
|
||||
# Generate download page
|
||||
# And convert SPDX license to license from lib
|
||||
meta = ext.meta // {
|
||||
downloadPage = marketplaceBaseURL + "${publisher}.${name}";
|
||||
license = lib.getLicenseFromSpdxId ext.meta.license;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
# Just calls buildExtension for each extension found in publisher.extensionName attrsets
|
||||
transformExtensions = extensions: lib.mapAttrs (publisher: ext: lib.mapAttrs (buildExtension publisher) ext) extensions;
|
||||
in
|
||||
transformExtensions extensions
|
38
packages/vscode-extensions/extensions.toml
Normal file
38
packages/vscode-extensions/extensions.toml
Normal file
|
@ -0,0 +1,38 @@
|
|||
[LeonardSSH.vscord.info]
|
||||
version = "5.2.12"
|
||||
hash = "sha256-WGDEizYG6UAqe1jnhvjfFouXDA9Yr5P+BjxPahAIsTE="
|
||||
|
||||
[LeonardSSH.vscord.meta]
|
||||
description = "Highly customizable Discord Rich Presence extension for Visual Studio Code"
|
||||
homepage = "https://github.com/LeonardSSH/vscord"
|
||||
license = "MIT"
|
||||
|
||||
|
||||
[Catppuccin.catppuccin-vsc-icons.info]
|
||||
version = "1.13.0"
|
||||
hash = "sha256-4gsblUMcN7a7UgoklBjc+2uiaSERq1vmi0exLht+Xi0="
|
||||
|
||||
[Catppuccin.catppuccin-vsc-icons.meta]
|
||||
description = "Catppuccin Icons for VSCode/VSCodium"
|
||||
homepage = "https://github.com/catppuccin/vscode-icons.git"
|
||||
license = "MIT"
|
||||
|
||||
|
||||
[keifererikson.nightfox.info]
|
||||
version = "0.0.14"
|
||||
hash = "sha256-EZGKJMc/N+0V+9U/k12tUbzgfCNzWhdrouXRi7QOdyY="
|
||||
|
||||
[keifererikson.nightfox.meta]
|
||||
description = "A foxy theme for Visual Studio Code"
|
||||
homepage = "https://github.com/keifererikson/vscode-nightfox.git"
|
||||
license = "MIT"
|
||||
|
||||
|
||||
[willasm.comment-highlighter.info]
|
||||
version = "2.0.0"
|
||||
hash = "sha256-fBe0mYq0iWerxvBYF5jFS/dZizu65Nn1iHypo69Bb50="
|
||||
|
||||
[willasm.comment-highlighter.meta]
|
||||
description = "Colorful Comment Highlighter for Visual Studio Code"
|
||||
homepage = "https://github.com/willasm/comment-highlighter#readme"
|
||||
license = "MIT"
|
6
stackpkgs.nix
Normal file
6
stackpkgs.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{ callPackage }:
|
||||
|
||||
{
|
||||
compileOptimized = callPackage ./packages/compileOptimized.nix {};
|
||||
vscode-extensions = callPackage ./packages/vscode-extensions.nix {};
|
||||
}
|
Loading…
Reference in a new issue