initial commit

This commit is contained in:
Jonas Röger 2025-11-21 21:12:03 +01:00
commit 60257c85ea
Signed by: jonas
GPG Key ID: 4000EB35E1AE0F07
7 changed files with 185 additions and 0 deletions

17
.envrc Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# ^ make editor happy
#
# Use https://direnv.net/ to automatically load the dev shell.
#
if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4="
fi
watch_file nix/**
watch_file -- **/*.nix
# Adding files to git includes them in a flake
# But it is also a bit much reloading.
# watch_file .git/index .git/HEAD
use flake . --show-trace

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.direnv/*
build
result

32
CMakeLists.txt Normal file
View File

@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.10)
project(
mosh-me
VERSION 0.1.0
LANGUAGES CXX)
find_package(spdlog REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
libavcodec
libavformat
libavutil
)
# ##############################################################################
add_executable(mosh-me ${PROJECT_SOURCE_DIR}/app/mosh-me.cpp)
target_link_libraries(mosh-me PkgConfig::FFMPEG spdlog::spdlog)
target_compile_features(mosh-me PUBLIC cxx_std_23)
target_include_directories(mosh-me PRIVATE ${PROJECT_SOURCE_DIR}/include)
install(TARGETS mosh-me)
################################################################################
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES})
endif()

3
app/mosh-me.cpp Normal file
View File

@ -0,0 +1,3 @@
#include <spdlog/spdlog.h>
int main() { spdlog::info("Hello!!"); }

61
flake.lock generated Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1762980239,
"narHash": "sha256-8oNVE8TrD19ulHinjaqONf9QWCKK+w4url56cdStMpM=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "52a2caecc898d0b46b2b905f058ccc5081f842da",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763618868,
"narHash": "sha256-v5afmLjn/uyD9EQuPBn7nZuaZVV9r+JerayK/4wvdWA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a8d610af3f1a5fb71e23e08434d8d61a466fc942",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

50
flake.nix Normal file
View File

@ -0,0 +1,50 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} ({self, ...}: {
imports = [];
flake = {
overlays.mosh-me = final: prev: {
mosh-me = final.callPackage ./nix/mosh-me.nix {};
};
};
systems = [
"x86_64-linux"
];
perSystem = {
pkgs,
system,
self',
...
}: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
self.overlays.mosh-me
];
config = {};
};
packages.default = pkgs.mosh-me;
packages.mosh-me = pkgs.mosh-me;
devShells.default = self'.devShells.mosh-me;
devShells.mosh-me = pkgs.mkShellNoCC {
shellHook = ''
export CMAKE_EXPORT_COMPILE_COMMANDS=ON
export CMAKE_BUILD_TYPE=Debug
export CMAKE_GENERATOR=Ninja
'';
packages = [
pkgs.clang-tools
pkgs.cmake-language-server
pkgs.gdb
];
inputsFrom = [pkgs.mosh-me];
};
};
});
}

19
nix/mosh-me.nix Normal file
View File

@ -0,0 +1,19 @@
{
cmake,
lib,
ninja,
spdlog,
stdenv,
pkg-config,
ffmpeg,
}:
stdenv.mkDerivation (finalAttrs: {
name = "mosh-me";
src = ../.;
nativeBuildInputs = [cmake ninja pkg-config];
buildInputs = [ffmpeg spdlog];
cmakeFlags = [
(lib.cmakeBool "BUILD_TESTING" finalAttrs.doCheck)
];
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
})