migration: packages: example
new: lib
This commit is contained in:
parent
bcb50d3b87
commit
3ce10d2e35
14
apps/default.nix
Normal file
14
apps/default.nix
Normal file
@ -0,0 +1,14 @@
|
||||
{ self, nixpkgs, ... }:
|
||||
let
|
||||
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ];
|
||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||
|
||||
in forAllSystems(system: let
|
||||
pkgs = nixpkgsFor.${system};
|
||||
bpkgs = self.packages.${system};
|
||||
blib = self.lib;
|
||||
in {
|
||||
|
||||
example = blib.mkApp { drv = bpkgs.example; name = "hello-nix"; };
|
||||
|
||||
})
|
@ -9,6 +9,9 @@
|
||||
};
|
||||
|
||||
outputs = inputs @ { self, nixpkgs, home-manager, agenix, ... }: {
|
||||
|
||||
lib = import ./lib {};
|
||||
|
||||
nixosConfigurations = {
|
||||
astora = with nixpkgs; lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
@ -29,5 +32,9 @@
|
||||
templates = {
|
||||
rust = { path = ./templates/rust; description = "Basic Rust template"; };
|
||||
};
|
||||
|
||||
packages = import ./packages { inherit self nixpkgs; };
|
||||
|
||||
apps = import ./apps { inherit self nixpkgs; };
|
||||
};
|
||||
}
|
||||
|
8
lib/default.nix
Normal file
8
lib/default.nix
Normal file
@ -0,0 +1,8 @@
|
||||
{ ... }:
|
||||
{
|
||||
mkApp = { drv, name ? drv.pname, binPath ? "/bin/${name}" }:
|
||||
{
|
||||
type = "app";
|
||||
program = "${drv}${binPath}";
|
||||
};
|
||||
}
|
10
packages/default.nix
Normal file
10
packages/default.nix
Normal file
@ -0,0 +1,10 @@
|
||||
{ self, nixpkgs, ... }:
|
||||
let
|
||||
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ];
|
||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||
|
||||
in forAllSystems(system: let pkgs = nixpkgsFor.${system}; in {
|
||||
|
||||
example = pkgs.callPackage ./example {};
|
||||
|
||||
})
|
10
packages/example/CMakeLists.txt
Normal file
10
packages/example/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(hello-nix LANGUAGES CXX)
|
||||
|
||||
add_executable(hello-nix source/example.cpp)
|
||||
|
||||
install(
|
||||
TARGETS hello-nix
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
|
||||
)
|
19
packages/example/default.nix
Normal file
19
packages/example/default.nix
Normal file
@ -0,0 +1,19 @@
|
||||
{ stdenv, lib, pkgs, ... }:
|
||||
stdenv.mkDerivation {
|
||||
pname = "example";
|
||||
version = "1.0";
|
||||
|
||||
# local source
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [ cmake ninja ];
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://www.example.org/";
|
||||
description = "Example with hello nix.";
|
||||
license = licenses.cc0;
|
||||
platforms = platforms.linux;
|
||||
maintainers = [];
|
||||
broken = false;
|
||||
};
|
||||
}
|
27
packages/example/flake.lock
generated
Normal file
27
packages/example/flake.lock
generated
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1694422566,
|
||||
"narHash": "sha256-lHJ+A9esOz9vln/3CJG23FV6Wd2OoOFbDeEs4cMGMqc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3a2786eea085f040a66ecde1bc3ddc7099f6dbeb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
71
packages/example/flake.old.nix
Normal file
71
packages/example/flake.old.nix
Normal file
@ -0,0 +1,71 @@
|
||||
{
|
||||
description = "Example with hello nix.";
|
||||
nixConfig.bash-prompt = "\[nix-develop\]$ ";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, ... }:
|
||||
let
|
||||
systems = [ "x86_64-linux" ];
|
||||
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||
|
||||
in {
|
||||
packages = forAllSystems (system: {
|
||||
example = let
|
||||
pkgs = nixpkgsFor.${system};
|
||||
pname = "example";
|
||||
version = "1.0";
|
||||
|
||||
in pkgs.stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
|
||||
# local source
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [ cmake ninja ];
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
homepage = "https://www.example.org/";
|
||||
description = "Example with hello nix.";
|
||||
license = licenses.cc0;
|
||||
platforms = platforms.linux;
|
||||
maintainers = [];
|
||||
broken = false;
|
||||
};
|
||||
};
|
||||
|
||||
default = self.packages.${system}.example;
|
||||
});
|
||||
|
||||
devShells = forAllSystems (system: {
|
||||
example = let
|
||||
pkgs = nixpkgsFor.${system};
|
||||
example = self.packages.${system}.example;
|
||||
|
||||
in pkgs.mkShellNoCC {
|
||||
packages = [
|
||||
example
|
||||
];
|
||||
};
|
||||
|
||||
default = self.devShells.${system}.example;
|
||||
});
|
||||
|
||||
apps = forAllSystems (system: {
|
||||
example = let
|
||||
pkgs = nixpkgsFor.${system};
|
||||
example = self.packages.${system}.example;
|
||||
|
||||
in {
|
||||
type = "app";
|
||||
program = "${example}/bin/hello-nix";
|
||||
};
|
||||
|
||||
default = self.apps.${system}.example;
|
||||
});
|
||||
|
||||
};
|
||||
}
|
8
packages/example/source/example.cpp
Normal file
8
packages/example/source/example.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <iostream>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
std::cout << "Hello Nix!" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user