meta: refactor c and dotnet

This commit is contained in:
Artur Manuel 2025-03-26 16:14:46 +00:00
commit a4368b5ddc
Signed by: amadaluzia
SSH key fingerprint: SHA256:Zwg7gBuZyaG48ucAZneJwltiXu0+tJb7c3lYt9AYlLg
14 changed files with 53 additions and 252 deletions

View file

@ -1,28 +1,21 @@
{
description = "REPLACE_DESC";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; };
outputs = {
self,
nixpkgs,
}: let
inherit (nixpkgs) lib;
forAllSystems = f:
lib.genAttrs ["x86_64-linux" "aarch64-linux"] (system:
f {
pkgs = import nixpkgs {
inherit system;
};
});
in {
packages = forAllSystems ({pkgs}: {
default = pkgs.callPackage ./flake/default.nix {};
REPLACE_ME = self.packages.${pkgs.system}.default;
});
outputs = { self, nixpkgs, }:
let
inherit (nixpkgs) lib;
forAllSystems = f:
lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]
(system: f { pkgs = import nixpkgs { inherit system; }; });
in {
packages = forAllSystems ({ pkgs }: {
default = pkgs.callPackage ./flake/default.nix { };
REPLACE_ME = self.packages.${pkgs.system}.default;
});
formatter = forAllSystems ({pkgs}: pkgs.callPackage ./flake/formatter.nix {});
};
formatter =
forAllSystems ({ pkgs }: pkgs.callPackage ./flake/formatter.nix { });
};
}

View file

@ -1,9 +1,4 @@
{
stdenv,
lib,
meson,
ninja,
}:
{ stdenv, lib, meson, ninja, }:
stdenv.mkDerivation {
pname = "REPLACE_ME";
version = "1";
@ -13,10 +8,7 @@ stdenv.mkDerivation {
filter = path: _type: baseNameOf path != ".git";
};
nativeBuildInputs = [
meson
ninja
];
nativeBuildInputs = [ meson ninja ];
installPhase = ''
mkdir -p $out/bin

View file

@ -1,20 +1,10 @@
{
writeShellApplication,
alejandra,
llvmPackages_19,
fd,
}:
{ writeShellApplication, nixfmt, deadnix, statix, llvmPackages_19, fd, }:
writeShellApplication {
name = "formatter";
runtimeInputs = [
alejandra
llvmPackages_19.clang-tools
fd
];
runtimeInputs = [ nixfmt deadnix statix llvmPackages_19.clang-tools fd ];
text = ''
fd --extension nix -X alejandra -- {}
fd --extension nix -X deadnix -e -- {}
fd --extension nix -x statix fix -- {}
fd --extension c -X clang-format --verbose -i -- {}
fd -e nix -X nixfmt {} \; -X deadnix -e {}
fd -e nix -x statix fix {}
fd -e c -e h -X clang-format --verbose -i {}
'';
}

View file

@ -1,6 +1,6 @@
using System;
namespace DotnetApplication {
namespace CHANGE_NAME {
class Program {
static void Main(string[] args) {
Console.WriteLine("Hello, world!");

View file

@ -1,68 +0,0 @@
{
"format": 1,
"restore": {
"/home/artur/Projects/C#/JSchlattVideoGame/JSchlattVideoGame.csproj": {}
},
"projects": {
"/home/artur/Projects/C#/JSchlattVideoGame/JSchlattVideoGame.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/artur/Projects/C#/JSchlattVideoGame/JSchlattVideoGame.csproj",
"projectName": "JSchlattVideoGame",
"projectPath": "/home/artur/Projects/C#/JSchlattVideoGame/JSchlattVideoGame.csproj",
"packagesPath": "/home/artur/.nuget/packages/",
"outputPath": "/home/artur/Projects/C#/JSchlattVideoGame/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/artur/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"/nix/store/0w5k79zvjzingpnzz07ijqjbgsylcgfa-dotnet-sdk-9.0.100/share/dotnet/library-packs": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "all"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/nix/store/0w5k79zvjzingpnzz07ijqjbgsylcgfa-dotnet-sdk-9.0.100/share/dotnet/sdk/9.0.100/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/artur/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/artur/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/artur/.nuget/packages/" />
</ItemGroup>
</Project>

View file

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View file

@ -1,73 +0,0 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"/home/artur/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/artur/Projects/C#/JSchlattVideoGame/JSchlattVideoGame.csproj",
"projectName": "JSchlattVideoGame",
"projectPath": "/home/artur/Projects/C#/JSchlattVideoGame/JSchlattVideoGame.csproj",
"packagesPath": "/home/artur/.nuget/packages/",
"outputPath": "/home/artur/Projects/C#/JSchlattVideoGame/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/artur/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"/nix/store/0w5k79zvjzingpnzz07ijqjbgsylcgfa-dotnet-sdk-9.0.100/share/dotnet/library-packs": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "all"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/nix/store/0w5k79zvjzingpnzz07ijqjbgsylcgfa-dotnet-sdk-9.0.100/share/dotnet/sdk/9.0.100/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View file

@ -1,8 +0,0 @@
{
"version": 2,
"dgSpecHash": "1YIpH04Ngl4=",
"success": true,
"projectFilePath": "/home/artur/Projects/C#/JSchlattVideoGame/JSchlattVideoGame.csproj",
"expectedPackageFiles": [],
"logs": []
}

View file

@ -9,7 +9,7 @@
"narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9",
"rev": "205b12d8b7cd4802fbcb8e8ef6aCHANGE_VER8781a4f9",
"type": "github"
},
"original": {

View file

@ -1,42 +1,27 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
};
outputs = inputs @ {
self,
nixpkgs,
...
}:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux"];
flake.overlays.default = final: prev: {
dotnet-application = final.callPackage ./nix/derivation.nix {};
};
perSystem = {
pkgs,
system,
self',
...
}: {
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
};
outputs =
{
self,
nixpkgs,
systems
}: let
pkgsFor = nixpkgs.legacyPackages;
forAllSystems = f: nixpkgs.lib.genAttrs (import systems) (system: f system pkgsFor.${system});
in {
packages = forAllSystems (system: pkgs: {
default = pkgs.callPackage ./flake/package.nix { };
CHANGE_NAME = self.packages.${system}.default;
});
packages = {
inherit (pkgs) dotnet-application;
default = self'.packages.dotnet-application;
};
devShells = forAllSystems (_: pkgs: {
default = pkgs.callPackage ./flake/shell.nix { };
});
devShells.default = pkgs.mkShell {
packages = [
pkgs.dotnetCorePackages.dotnet_9.sdk
];
};
};
formatter = forAllSystems (_: pkgs: pkgs.callPackage ./flake/formatter.nix { });
};
}

View file

@ -3,11 +3,11 @@
dotnetCorePackages,
}:
buildDotnetModule {
pname = "DotnetApplication";
version = "0.1.0";
pname = "CHANGE_NAME";
version = "CHANGE_VER";
src = ../.;
projectFile = "DotnetApplication/DotnetApplication.csproj";
projectFile = "CHANGE_NAME/CHANGE_NAME.csproj";
dotnet-sdk = dotnetCorePackages.dotnet_9.sdk;
dotnet-runtime = dotnetCorePackages.dotnet_9.runtime;
executables = ["DotnetApplication"];
executables = ["CHANGE_NAME"];
}

View file

@ -1,9 +1,16 @@
{
mkShell,
dotnetCorePackages,
nixfmt,
deadnix,
statix,
}:
mkShell {
name = "dotnet";
packages = [
dotnetCorePackages.dotnet_9.sdk
nixfmt
deadnix
statix
];
}